From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Adam Zabrocki <pi3@pi3.com.pl>
Cc: Jessica Yu <jeyu@kernel.org>,
Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>,
linux-kernel@vger.kernel.org, Solar Designer <solar@openwall.com>
Subject: Re: [PATCH] module: invoke kobject uevent before sending LIVE notification
Date: Wed, 13 Jan 2021 08:44:47 +0100 [thread overview]
Message-ID: <X/6k73cc9ft8be5o@kroah.com> (raw)
In-Reply-To: <20210113003310.GA3040@pi3.com.pl>
On Wed, Jan 13, 2021 at 01:33:10AM +0100, Adam Zabrocki wrote:
> The recent change "module: delay kobject uevent until after module init
> call", while helping avoid a race between udev/systemd and the module
> loader, made it unnecessarily more difficult to monitor kernel module
> integrity by out-of-tree projects such as Linux Kernel Runtime Guard.
We don't support out-of-tree kernel code, sorry.
> Specifically, that change delayed the kobject uevent unnecessarily too far,
> to until after sending a MODULE_STATE_LIVE notification. As the uevent
> modifies internal state of the KOBJ itself, this violated the assumption
> (non-guaranteed yet handy while we can maintain it) that the KOBJ remains
> consistent and can be integrity-checked as soon as the module is LIVE.
>
> To make all of these projects happy at once, move the kobject KOBJ_ADD
> uevent to just before sending the MODULE_STATE_LIVE notification.
>
> Fixes: 38dc717e9715 ("module: delay kobject uevent until after module init call")
> Signed-off-by: Adam Zabrocki <pi3@pi3.com.pl>
> ---
> kernel/module.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 4bf30e4b3eaa..7d56b1b07237 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -3681,14 +3681,14 @@ static noinline int do_init_module(struct module *mod)
> dump_stack();
> }
>
> + /* Delay uevent until module has finished its init routine */
> + kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
> +
> /* Now it's a first class citizen! */
> mod->state = MODULE_STATE_LIVE;
> blocking_notifier_call_chain(&module_notify_list,
> MODULE_STATE_LIVE, mod);
>
> - /* Delay uevent until module has finished its init routine */
> - kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
> -
No, the code is correct as-is, userspace should be told _after_ the
kernel itself has handled all of the needed housekeeping of the module
being added.
so consider this:
Nacked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
prev parent reply other threads:[~2021-01-13 7:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-10 17:54 Linux Kernel module notification bug Adam Zabrocki
2021-01-11 14:20 ` Jessica Yu
2021-01-12 0:15 ` Adam Zabrocki
2021-01-12 10:46 ` Jessica Yu
2021-01-12 11:00 ` Greg Kroah-Hartman
2021-01-13 0:33 ` [PATCH] module: invoke kobject uevent before sending LIVE notification Adam Zabrocki
2021-01-13 7:44 ` Greg Kroah-Hartman [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=X/6k73cc9ft8be5o@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=jeyu@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nmoreychaisemartin@suse.com \
--cc=pi3@pi3.com.pl \
--cc=solar@openwall.com \
/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.