From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-trace-kernel@vger.kernel.org, linux-modules@vger.kernel.org
Subject: Re: [PATCH 1/2] module: pull out add_taint_module() to be public
Date: Wed, 26 Aug 2026 12:39:34 +0200 [thread overview]
Message-ID: <2026082652-thigh-backtrack-d2fc@gregkh> (raw)
In-Reply-To: <20260826102921.5B81B1F000E9@smtp.kernel.org>
On Wed, Aug 26, 2026 at 10:29:20AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Potential NULL pointer dereference in `add_taint_module` if called by built-in code passing `THIS_MODULE`.
> - [Low] Syntax error in the `!CONFIG_MODULES` stub for `add_taint_module` causes an unconditional build failure due to an undeclared identifier.
> --
>
> commit 371e790be5ebdf80163e6326d6a8f79c05f469bb
> Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> module: pull out add_taint_module() to be public
>
> This commit makes add_taint_module() public so other kernel code can call it.
> It also provides a fallback stub that simply calls add_taint() when modules
> are not enabled.
>
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 96cc98568eea5..25221539e6459 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> [ ... ]
> > @@ -877,6 +880,11 @@ static inline bool module_is_coming(struct module *mod)
> > static inline void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data)
> > {
> > }
> > +
> > +static inline void add_taint_module(struct module *mod, unsigned flag, enum lockdep_ok)
> > +{
> > + add_taint(flag, lockdep_ok);
> > +}
>
> [Severity: Low]
> Is this a build regression when CONFIG_MODULES is disabled?
>
> The third parameter in this stub specifies the type enum lockdep_ok but omits
> a variable name. The function body then passes lockdep_ok to add_taint(),
> which resolves to the enum tag rather than a local variable, causing the
> compiler to halt with an undeclared identifier error.
Ah, missed this, will do a v2 with this fixed, my bad.
> > #endif /* CONFIG_MODULES */
> >
> > #ifdef CONFIG_SYSFS
> > diff --git a/kernel/module/main.c b/kernel/module/main.c
> > index d0e1e0bd2ad06..99cedb9618988 100644
> > --- a/kernel/module/main.c
> > +++ b/kernel/module/main.c
> [ ... ]
> > @@ -191,8 +191,17 @@ static inline int strong_try_module_get(struct module *mod)
> > return -ENOENT;
> > }
> >
> > -static inline void add_taint_module(struct module *mod, unsigned flag,
> > - enum lockdep_ok lockdep_ok)
> > +/**
> > + * add_taint_module: add a taint flag if not already set for a specific module
> > + * @mod: pointer to the module that caused the problem
> > + * @flag: one of the TAINT_* constants.
> > + * @lockdep_ok: whether lock debugging is still OK.
> > + *
> > + * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for
> > + * some noteworthy-but-not-corrupting cases, it can be set to true.
> > + */
> > +void add_taint_module(struct module *mod, unsigned flag,
> > + enum lockdep_ok lockdep_ok)
> > {
> > add_taint(flag, lockdep_ok);
> > set_bit(flag, &mod->taints);
>
> [Severity: High]
> Is this a regression that could unconditionally dereference a NULL pointer?
>
> If built-in code calls this function (for example, passing THIS_MODULE which
> evaluates to NULL for built-in modules), mod->taints will be accessed without
> a standard if (mod) safeguard.
>
> This could lead to a fatal page fault if, for instance, a local root user
> writes to a built-in driver's bind or unbind sysfs file which then calls
> add_taint_module(drv->owner, ...).
Oops, missed this one too, I only tested this with a module, not a
built-in driver. Will fix it up for v2.
next prev parent reply other threads:[~2026-08-26 10:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 9:19 [PATCH 0/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-08-26 9:19 ` [PATCH 1/2] module: pull out add_taint_module() to be public Greg Kroah-Hartman
2026-08-26 10:29 ` sashiko-bot
2026-08-26 10:39 ` Greg Kroah-Hartman [this message]
2026-08-26 11:13 ` Aaron Tomlin
2026-08-26 11:54 ` Greg Kroah-Hartman
2026-08-27 13:36 ` Johan Hovold
2026-08-27 14:30 ` Greg Kroah-Hartman
2026-08-26 9:19 ` [PATCH 2/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-08-26 10:34 ` sashiko-bot
2026-08-26 11:58 ` Bradley Morgan
2026-08-26 13:10 ` Greg KH
2026-08-26 14:26 ` Steven Rostedt
2026-08-26 14:34 ` Bradley Morgan
2026-08-27 13:33 ` Johan Hovold
2026-09-25 21:19 ` Dmitry Torokhov
2026-10-02 14:40 ` Johan Hovold
2026-08-26 13:33 ` [PATCH 0/2] " Michal Pecio
2026-08-26 14:25 ` Greg Kroah-Hartman
2026-08-26 15:35 ` Michal Pecio
2026-08-26 15:44 ` Greg Kroah-Hartman
2026-08-26 17:09 ` Michal Pecio
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=2026082652-thigh-backtrack-d2fc@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.