mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	David Howells <dhowells@redhat.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH 1/2] test: add minimal module for verification testing
Date: Tue, 3 Dec 2013 13:36:34 -0800	[thread overview]
Message-ID: <20131203133634.e3e4264d7e027c858c0c9268@linux-foundation.org> (raw)
In-Reply-To: <1386106054-27636-2-git-send-email-keescook@chromium.org>

On Tue,  3 Dec 2013 13:27:33 -0800 Kees Cook <keescook@chromium.org> wrote:

> When doing module loading verification tests (for example, with module
> singing, or LSM hooks), it is very handy to have a module that can be
> built on all systems under test, isn't auto-loaded at boot, and has
> no device or similar dependencies. This creates the "test_module.ko"
> module for that purpose, which only reports its load and unload to printk.
> 
> --- /dev/null
> +++ b/kernel/test_module.c
> @@ -0,0 +1,26 @@
> +/*
> + * "hello world" kernel module
> + */
> +
> +#define pr_fmt(fmt) "test_module: " fmt
> +
> +#include <linux/module.h>

It really should have a whole bunch more includes, rather than relying
on winning the nested include lottery.

> +static int __init test_module_init(void)
> +{
> +	pr_info("Hello, world\n");

pr_info is maybe too low a facility level?  Pretty much the whole point
of the module is to print this message, so let's ensure that it is visible.

> +	return 0;
> +}
> +
> +module_init(test_module_init);
> +
> +static void __exit test_module_exit(void)
> +{
> +	pr_info("Goodbye\n");
> +}
> +
> +module_exit(test_module_exit);
> +
> +MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
> +MODULE_LICENSE("GPL");
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index db25707aa41b..20abc92032e0 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -1578,6 +1578,20 @@ config DMA_API_DEBUG
>  	  This option causes a performance degredation.  Use only if you want
>  	  to debug device drivers. If unsure, say N.
>  
> +config TEST_MODULE
> +	tristate "Test module loading with 'hello world' module"
> +	default n
> +	depends on m
> +	help
> +	  This builds the "test_module" module that emits "Hello, world"
> +	  on printk when loaded. It is designed to be used for basic
> +	  evaluation of the module loading subsystem (for example when
> +	  validating module verification). It lacks any extra dependencies,
> +	  and will not normally be loaded by the system unless explicitly
> +	  request by name.

Would be useful to have a comment along these lines in test_module.c,
so readers know why it exists.


  reply	other threads:[~2013-12-03 21:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 21:27 [PATCH 0/2] test modules Kees Cook
2013-12-03 21:27 ` [PATCH 1/2] test: add minimal module for verification testing Kees Cook
2013-12-03 21:36   ` Andrew Morton [this message]
2013-12-03 23:52   ` Rusty Russell
2013-12-03 21:27 ` [PATCH 2/2] test: check copy_to/from_user boundary validation Kees Cook
2013-12-03 21:47   ` Andrew Morton
2013-12-03 22:03     ` Kees Cook
2013-12-03 21:53   ` Joe Perches

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=20131203133634.e3e4264d7e027c858c0c9268@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dhowells@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rusty@rustcorp.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®