From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Hyeontaek Lim <jennystr233@gmail.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
syzbot+d164947c037324221043@syzkaller.appspotmail.com
Subject: Re: [PATCH] kobject_uevent: fix OOB read in kobject_action_type()
Date: Mon, 28 Sep 2026 07:14:28 +0200 [thread overview]
Message-ID: <2026092806-life-amazingly-e68d@gregkh> (raw)
In-Reply-To: <20260927174241.36888-1-jennystr233@gmail.com>
On Mon, Sep 28, 2026 at 02:42:41AM +0900, Hyeontaek Lim wrote:
> kobject_action_type() matches a user-supplied action string against
> the short "add"/"remove"/"change"/... literals in kobject_actions[]
> using strncmp() with a length (count_first) derived from the size of
> the user-supplied buffer (up to the first space, or the whole write).
>
> strncmp() correctly stops comparing as soon as it hits a NUL byte in
> either string, so a caller can make it report a "match" against a
> short literal like "add" by embedding a NUL right after "add" in an
> otherwise much longer buffer (e.g. write "add\0" followed by 391
> bytes of arbitrary padding, with no space, so count_first stays at
> the full write length).
>
> The subsequent bounds check then indexes the matched literal at that
> same, much larger offset:
>
> if (kobject_actions[action][count_first] != '\0')
>
> which reads far past the end of the 4-byte "add" literal, into
> whatever object happens to follow it in .rodata (observed to land
> inside uevent_helper_sysctl_table on the reporter's build).
>
> Fix this by checking the literal's real length against count_first
> before doing the strncmp()/indexing at all, instead of trusting that
> a strncmp() "match" implies the lengths agree.
>
> Reported-by: syzbot+d164947c037324221043@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d164947c037324221043
> Signed-off-by: Hyeontaek Lim <jennystr233@gmail.com>
> ---
> lib/kobject_uevent.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> index xxxxxxx..xxxxxxx 100644
> --- a/lib/kobject_uevent.c
> +++ b/lib/kobject_uevent.c
> @@ -78,10 +78,11 @@ static int kobject_action_type(const char *buf, size_t count,
> count_first = count;
>
> for (action = 0; action < ARRAY_SIZE(kobject_actions); action++) {
> + if (strlen(kobject_actions[action]) != count_first)
> + continue;
> if (strncmp(kobject_actions[action], buf, count_first) != 0)
> continue;
> - if (kobject_actions[action][count_first] != '\0')
> - continue;
> if (args)
> *args = args_start;
> *type = action;
>
Hasn't this been resolved already?
prev parent reply other threads:[~2026-09-28 5:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 17:42 Hyeontaek Lim
2026-09-28 5:14 ` 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=2026092806-life-amazingly-e68d@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=jennystr233@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=syzbot+d164947c037324221043@syzkaller.appspotmail.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 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®