From: David Gow <davidgow@google.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Brendan Higgins <brendanhiggins@google.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>,
Kees Cook <keescook@chromium.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Greg KH <gregkh@linuxfoundation.org>,
"Guilherme G . Piccoli" <gpiccoli@igalia.com>,
Sebastian Reichel <sre@kernel.org>,
John Ogness <john.ogness@linutronix.de>,
Joe Fradley <joefradley@google.com>,
Daniel Latypov <dlatypov@google.com>,
KUnit Development <kunit-dev@googlegroups.com>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jani Nikula <jani.nikula@linux.intel.com>,
Lucas De Marchi <lucas.demarchi@intel.com>,
Aaron Tomlin <atomlin@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v3 3/3] selftest: Taint kernel when test module loaded
Date: Sat, 14 May 2022 16:34:23 +0800 [thread overview]
Message-ID: <CABVgOSkhr6xfgXZWW6UdbU4MpAvqsDOsqVP0THsH0gVB949HjA@mail.gmail.com> (raw)
In-Reply-To: <Yn57d1e6k8uv2uQj@bombadil.infradead.org>
On Fri, May 13, 2022 at 11:38 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> On Fri, May 13, 2022 at 04:32:13PM +0800, David Gow wrote:
> > Make any kselftest test module (using the kselftest_module framework)
> > taint the kernel with TAINT_TEST on module load.
> >
> > Note that several selftests use kernel modules which are not based on
> > the kselftest_module framework, and so will not automatically taint the
> > kernel. These modules will have to be manually modified if they should
> > taint the kernel this way.
> >
> > Similarly, selftests which do not load modules into the kernel generally
> > should not taint the kernel (or possibly should only do so on failure),
> > as it's assumed that testing from user-space should be safe. Regardless,
> > they can write to /proc/sys/kernel/tainted if required.
> >
> > Signed-off-by: David Gow <davidgow@google.com>
>
> Not all selftest modules use KSTM_MODULE_LOADERS() so I'd like to see a
> modpost target as well, otherwise this just covers a sliver of
> selftests.
>
My personal feeling is that the ideal way of solving this is actually
to port those modules which aren't using KSTM_MODULE_LOADERS() (or
KUnit, or some other system) to do so, or to otherwise manually tag
them as selftests and/or make them taint the kernel.
That being said, we can gain a bit my making the module-loading
helpers in kselftest/module.sh manually taint the kernel with
/proc/sys/kernel/tainted, which will catch quite a few of them (even
if tainting from userspace before they're loaded is suboptimal).
I've also started experimenting with a "test" MODULE_INFO field, which
modpost would add with the -t option. That still requires sprinkling
MODULE_INFO() everwhere, or the '-t' option to a bunch of makefiles,
or doing something more drastic to set it automatically for modules in
a given directory / makefile. Or the staging thing of checking the
directory / prefix in modpost.
I'll play around some more and have something to show in v4. (If we
have a MODULE_INFO field, we should use it for KUnit modules, but we'd
still have to taint the kernel manually for built-in tests anyway, so
it'd be redundant...)
-- David
prev parent reply other threads:[~2022-05-14 8:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220429043913.626647-1-davidgow@google.com>
[not found] ` <20220430030019.803481-1-davidgow@google.com>
[not found] ` <Ym7P7mCoMiQq99EM@bombadil.infradead.org>
2022-05-01 18:24 ` [PATCH v2] kunit: Taint kernel if any tests run Luis Chamberlain
2022-05-03 6:49 ` David Gow
2022-05-04 14:51 ` Luis Chamberlain
2022-05-04 16:25 ` Daniel Latypov
2022-05-04 18:46 ` Luis Chamberlain
2022-05-04 19:19 ` Daniel Latypov
2022-05-04 21:12 ` Luis Chamberlain
2022-05-05 5:57 ` Luis Chamberlain
2022-05-06 7:01 ` David Gow
2022-05-09 20:43 ` Luis Chamberlain
2022-05-13 8:32 ` [PATCH v3 1/3] panic: Taint kernel if tests are run David Gow
2022-05-13 15:35 ` Luis Chamberlain
2022-05-17 20:45 ` Brendan Higgins
2022-05-13 8:32 ` [PATCH v3 2/3] kunit: Taint the kernel when KUnit " David Gow
2022-05-13 15:36 ` Luis Chamberlain
2022-05-13 19:08 ` Daniel Latypov
2022-05-14 3:04 ` David Gow
2022-05-14 19:25 ` Daniel Latypov
2022-05-17 20:58 ` Brendan Higgins
2022-05-17 20:58 ` Brendan Higgins
2022-05-13 8:32 ` [PATCH v3 3/3] selftest: Taint kernel when test module loaded David Gow
2022-05-13 15:38 ` Luis Chamberlain
2022-05-14 8:34 ` David Gow [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=CABVgOSkhr6xfgXZWW6UdbU4MpAvqsDOsqVP0THsH0gVB949HjA@mail.gmail.com \
--to=davidgow@google.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=atomlin@redhat.com \
--cc=brendanhiggins@google.com \
--cc=corbet@lwn.net \
--cc=dlatypov@google.com \
--cc=gpiccoli@igalia.com \
--cc=gregkh@linuxfoundation.org \
--cc=jani.nikula@linux.intel.com \
--cc=joefradley@google.com \
--cc=john.ogness@linutronix.de \
--cc=keescook@chromium.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=mcgrof@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=sre@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).