From: Greg KH <gregkh@linuxfoundation.org>
To: Ren Wei <weir@nebusec.ai>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
rafael@kernel.org, dakr@kernel.org, johan@kernel.org,
akpm@linux-foundation.org, kay.sievers@vrfy.org, vega@nebusec.ai,
caoruide123@gmail.com
Subject: Re: [PATCH driver-core 1/1] kobject: reserve an envp slot for the terminator
Date: Mon, 23 Nov 2026 13:57:24 +0100 [thread overview]
Message-ID: <2026112301-jingle-multiply-c72d@gregkh> (raw)
In-Reply-To: <cd35c5682ebe0f5a58fa6beed90bb7d0e7d5e9a2.1795426787.git.caoruide123@gmail.com>
On Mon, Nov 23, 2026 at 08:16:37PM +0800, Ren Wei wrote:
> From: Ruide Cao <caoruide123@gmail.com>
>
> add_uevent_var() currently allows envp_idx to reach ARRAY_SIZE(envp).
> This fills the final pointer slot without leaving room for the NULL
> terminator expected by usermode helper consumers.
>
> A synthetic uevent can supply enough variables to make this happen.
> When CONFIG_UEVENT_HELPER is enabled, kernel_execve() then scans beyond
> the array while counting the environment and may dereference arbitrary
> data as a string pointer.
>
> Reserve the final slot so an environment is always terminated.
>
> Fixes: 7eff2e7a8b65 ("Driver core: change add_uevent_var to use a struct")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Signed-off-by: Ruide Cao <caoruide123@gmail.com>
> Signed-off-by: Ren Wei <weir@nebusec.ai>
> ---
> lib/kobject_uevent.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> index 1d29378d4f55..f7aa67d6ee54 100644
> --- a/lib/kobject_uevent.c
> +++ b/lib/kobject_uevent.c
> @@ -673,7 +673,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
> va_list args;
> int len;
>
> - if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
> + if (env->envp_idx >= ARRAY_SIZE(env->envp) - 1) {
> WARN(1, KERN_ERR "add_uevent_var: too many keys\n");
> return -ENOMEM;
> }
As "simple" as this looks, I think there's been problems with it in the
past. Have you tested this?
thanks,
greg k-h
next prev parent reply other threads:[~2026-11-23 12:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 12:16 [PATCH driver-core 0/1] " Ren Wei
2026-11-23 12:16 ` [PATCH driver-core 1/1] " Ren Wei
2026-11-23 12:57 ` Greg KH [this message]
2026-11-23 12:56 ` [PATCH driver-core 0/1] " Greg KH
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=2026112301-jingle-multiply-c72d@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=caoruide123@gmail.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=johan@kernel.org \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=vega@nebusec.ai \
--cc=weir@nebusec.ai \
/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®