All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] lkdtm: hide unused functions
Date: Fri, 15 Jul 2016 15:54:38 -0700	[thread overview]
Message-ID: <CAGXu5jKpiAE1UCAoX4HjqOOMWZbOzRJqMu=KQjZ0iMkmuQ5qEA@mail.gmail.com> (raw)
In-Reply-To: <2180832.bWdqFupBK3@wuerfel>

On Fri, Jul 15, 2016 at 4:35 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> A conversion of the lkdtm core module added an "#ifdef CONFIG_KPROBES" check,
> but a number of functions then become unused:
>
> drivers/misc/lkdtm_core.c:340:16: error: 'lkdtm_debugfs_entry' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:122:12: error: 'jp_generic_ide_ioctl' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:114:12: error: 'jp_scsi_dispatch_cmd' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:106:12: error: 'jp_hrtimer_start' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:97:22: error: 'jp_shrink_inactive_list' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:89:13: error: 'jp_ll_rw_block' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:83:13: error: 'jp_tasklet_action' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:75:20: error: 'jp_handle_irq_event' defined but not used [-Werror=unused-function]
> drivers/misc/lkdtm_core.c:68:21: error: 'jp_do_irq' defined but not used [-Werror=unused-function]
>
> This adds the same #ifdef everywhere. There is probably a better way to do the
> same thing, but for now this avoids the new warnings.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: c479e3fd8870 ("lkdtm: use struct arrays instead of enums")

Ah! Thank you very much. I'm going to make a small change and get this
into my tree.

-Kees

> ---
>
> On Wednesday, July 6, 2016 3:33:31 PM CEST Kees Cook wrote:
>> +
>> +/* Define the possible places where we can trigger a crash point. */
>> +struct crashpoint crashpoints[] = {
>> +     CRASHPOINT("DIRECT",                    direct_entry,
>> +                NULL,                        NULL),
>> +#ifdef CONFIG_KPROBES
>> +     CRASHPOINT("INT_HARDWARE_ENTRY",        lkdtm_debugfs_entry,
>> +                "do_IRQ",                    jp_do_irq),
>> +     CRASHPOINT("INT_HW_IRQ_EN",             lkdtm_debugfs_entry,
>> +                "handle_IRQ_event",          jp_handle_irq_event),
>> +     CRASHPOINT("INT_TASKLET_ENTRY",         lkdtm_debugfs_entry,
>
> diff --git a/drivers/misc/lkdtm_core.c b/drivers/misc/lkdtm_core.c
> index de29a339242a..6bdef16f95a2 100644
> --- a/drivers/misc/lkdtm_core.c
> +++ b/drivers/misc/lkdtm_core.c
> @@ -53,12 +53,14 @@
>
>  #define DEFAULT_COUNT 10
>
> -static void lkdtm_handler(void);
>  static int lkdtm_debugfs_open(struct inode *inode, struct file *file);
>  static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
>                 size_t count, loff_t *off);
>  static ssize_t direct_entry(struct file *f, const char __user *user_buf,
>                             size_t count, loff_t *off);
> +
> +#ifdef CONFIG_KPROBES
> +static void lkdtm_handler(void);
>  static ssize_t lkdtm_debugfs_entry(struct file *f,
>                                    const char __user *user_buf,
>                                    size_t count, loff_t *off);
> @@ -128,7 +130,7 @@ static int jp_generic_ide_ioctl(ide_drive_t *drive, struct file *file,
>         return 0;
>  }
>  #endif
> -
> +#endif
>
>  /* Crash points */
>  struct crashpoint {
> @@ -240,7 +242,9 @@ struct crashtype *lkdtm_crashtype;
>
>  /* Global crash counter and spinlock. */
>  static int crash_count = DEFAULT_COUNT;
> +#ifdef CONFIG_KPROBES
>  static DEFINE_SPINLOCK(crash_count_lock);
> +#endif
>
>  /* Module parameters */
>  static int recur_count = -1;
> @@ -285,6 +289,7 @@ static noinline void lkdtm_do_action(struct crashtype *crashtype)
>         crashtype->func();
>  }
>
> +#ifdef CONFIG_KPROBES
>  /* Called by jprobe entry points. */
>  static void lkdtm_handler(void)
>  {
> @@ -307,6 +312,7 @@ static void lkdtm_handler(void)
>         if (do_it)
>                 lkdtm_do_action(lkdtm_crashtype);
>  }
> +#endif
>
>  static int lkdtm_register_cpoint(struct crashpoint *crashpoint,
>                                  struct crashtype *crashtype)
> @@ -337,6 +343,7 @@ static int lkdtm_register_cpoint(struct crashpoint *crashpoint,
>         return ret;
>  }
>
> +#ifdef CONFIG_KPROBES
>  static ssize_t lkdtm_debugfs_entry(struct file *f,
>                                    const char __user *user_buf,
>                                    size_t count, loff_t *off)
> @@ -374,6 +381,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,
>
>         return count;
>  }
> +#endif
>
>  /* Generic read callback that just prints out the available crash types */
>  static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
>



-- 
Kees Cook
Chrome OS & Brillo Security

      reply	other threads:[~2016-07-15 22:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 22:33 [PATCH 00/12] lkdtm: use struct arrays instead of enums Kees Cook
2016-07-06 22:33 ` [PATCH 01/12] lkdtm: add usercopy test for blocking kernel text Kees Cook
2016-07-06 22:33 ` [PATCH 02/12] lkdtm: drop "alloc_size" parameter Kees Cook
2016-07-06 22:33 ` [PATCH 03/12] lkdtm: split usercopy tests to separate file Kees Cook
2016-07-06 22:33 ` [PATCH 04/12] lkdtm: split memory permissions " Kees Cook
2016-07-06 22:33 ` [PATCH 05/12] lkdtm: split heap corruption " Kees Cook
2016-07-06 22:33 ` [PATCH 06/12] lkdtm: split remaining logic bug " Kees Cook
2016-07-06 22:33 ` [PATCH 07/12] lkdtm: remove intentional off-by-one array access Kees Cook
2016-07-06 22:33 ` [PATCH 08/12] lkdtm: rename "count" to "crash_count" Kees Cook
2016-07-06 22:33 ` [PATCH 09/12] lkdtm: rename globals for clarity Kees Cook
2016-07-06 22:33 ` [PATCH 10/12] lkdtm: reorganize module paramaters Kees Cook
2016-07-06 22:33 ` [PATCH 11/12] lkdtm: move jprobe entry points to start of source Kees Cook
2016-07-06 22:33 ` [PATCH 12/12] lkdtm: use struct arrays instead of enums Kees Cook
2016-07-15 11:35   ` [PATCH] lkdtm: hide unused functions Arnd Bergmann
2016-07-15 22:54     ` Kees Cook [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGXu5jKpiAE1UCAoX4HjqOOMWZbOzRJqMu=KQjZ0iMkmuQ5qEA@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.