Re: [PATCH driver-core 1/1] kobject: reserve an envp slot for the terminator

From: Greg KH

Date: Wed Nov 25 2026 - 05:00:14 EST



A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?


http://daringfireball.net/2007/07/on_top

On Wed, Nov 25, 2026 at 05:13:08PM +0800, Ruide Cao wrote:
> Hi Greg,
>
> You are right to be suspicious of this one, thanks. v1 was not good
> enough: the "- 1" lowers the limit for every uevent from 64 to 63,
> including events that never go near the usermode helper. In testing,
> a currently valid 64-variable event was rejected (with the "too many
> keys" WARN) on v1, on both the helper and the netlink-only path.
>
> The underlying bug is still real: when env->envp[] is completely full
> there is no slot left for the NULL terminator, so with
> CONFIG_UEVENT_HELPER the helper's envp is not terminated and
> kernel_execve() walks past the array (KASAN: strnlen <-
> copy_string_kernel <- kernel_execve, then panic).

This is an ai-response. {sigh}

Please do this work yourself.

> v2 keeps the 64-variable capacity and instead adds one dedicated
> terminator slot (envp[UEVENT_NUM_ENVP + 1]), writes NULL after every
> successful add_uevent_var(), and also after zap_modalias_env() drops
> MODALIAS. struct kobj_uevent_env is kernel-internal, so the only
> visible change is 8 bytes.

What does this mean? Again, think about the problem, come up with a
valid solution, and write this all in your own words.

thanks,

greg k-h