From: "Vishal Moola (Fractile)" <vishal.moola@gmail.com>
To: Jiacheng Xu <stitch@zju.edu.cn>
Cc: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
akpm@linux-foundation.org, driver-core@lists.linux.dev
Subject: Re: [PATCH v2 RESEND] kobject: fix out-of-bounds access in kobject_action_type()
Date: Tue, 25 Aug 2026 13:12:33 +0100 [thread overview]
Message-ID: <ao2GsVJ6KSO7iMG7@fedora> (raw)
In-Reply-To: <20260825070525.76409-1-stitch@zju.edu.cn>
On Tue, Aug 25, 2026 at 03:05:25PM +0800, Jiacheng Xu wrote:
> kobject_action_type() uses the position of the first space in the input
> as the length of the uevent action. It then checks the byte at that
> position in the corresponding action string.
>
> An embedded NUL byte can make strncmp() report a match while
> count_first is already greater than the actual length of the action
> string. For example, the input "bind\0 ..." makes the parser access
> kobject_actions[KOBJ_BIND][5], which is beyond the end of the "bind"
> string.
>
> Use strlen() to verify that the input action length exactly matches the
> known action string before accepting the match. This avoids indexing
> the action string with an out-of-bounds offset.
Sounds sensible to me. This doesn't seem like something anyone should
intentionally be doing, and I assume users won't care about the additional
minor overhead of strlen().
From what I can tell, this does change the behavior for actions with Nul
embedded strings from 'undefined' to 'expected to fail.' I think that's worth
mentioning in the commit log.
> Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
Also, it appears the pattern predates this commit, so definitely double
check that tag :)
> Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
With those mentioned, feel free to add my tag:
Reviewed-by: Vishal Moola (Fractile) <vishal.moola@gmail.com>
> ---
> 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 ddbc4d7482d2..b03562301bfe 100644
> --- a/lib/kobject_uevent.c
> +++ b/lib/kobject_uevent.c
> @@ -83,7 +83,7 @@ static int kobject_action_type(const char *buf, size_t count,
> for (action = 0; action < ARRAY_SIZE(kobject_actions); action++) {
> if (strncmp(kobject_actions[action], buf, count_first) != 0)
> continue;
> - if (kobject_actions[action][count_first] != '\0')
> + if (strlen(kobject_actions[action]) != count_first)
> continue;
> if (args)
> *args = args_start;
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-08-25 12:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 6:26 [PATCH] kobject: fix out-of-bounds read in action parser Jiacheng Xu
2026-08-24 17:32 ` Vishal Moola (Fractile)
2026-08-25 3:54 ` Jiacheng Xu
2026-08-25 3:57 ` [PATCH v2] " Jiacheng Xu
2026-08-25 5:33 ` Greg KH
2026-08-25 6:26 ` [PATCH] " Jiacheng Xu
2026-08-25 6:46 ` Greg KH
2026-08-25 7:05 ` [PATCH v2 RESEND] kobject: fix out-of-bounds access in kobject_action_type() Jiacheng Xu
2026-08-25 7:35 ` Greg KH
2026-08-25 12:12 ` Vishal Moola (Fractile) [this message]
2026-09-20 5:37 ` [PATCH v3] " Jiacheng Xu
2026-09-20 6:04 ` Greg KH
2026-09-24 18:46 ` Danilo Krummrich
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=ao2GsVJ6KSO7iMG7@fedora \
--to=vishal.moola@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=rafael@kernel.org \
--cc=stitch@zju.edu.cn \
/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.