Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jiacheng Xu <stitch@zju.edu.cn>
Cc: vishal.moola@gmail.com, rafael@kernel.org, dakr@kernel.org,
	akpm@linux-foundation.org, driver-core@lists.linux.dev
Subject: Re: [PATCH v3] kobject: fix out-of-bounds access in kobject_action_type()
Date: Sun, 20 Sep 2026 08:04:38 +0200	[thread overview]
Message-ID: <2026092014-lumping-datebook-0076@gregkh> (raw)
In-Reply-To: <20260920053726.22626-1-stitch@zju.edu.cn>

On Sun, Sep 20, 2026 at 01:37:26PM +0800, Jiacheng Xu wrote:
> kobject_action_type() compares the input against each known action
> using strncmp() and then indexes the action string using count_first
> to check for an exact-length match.
> 
> An embedded NUL can make strncmp() return zero even when count_first
> exceeds the length of the action string. For example, the five-byte
> input "add\0X" makes the parser access kobject_actions[KOBJ_ADD][5],
> which is beyond the end of the "add" string.
> 
> Check the action string length with strlen() instead of indexing it
> with the input-derived offset. This rejects malformed action strings
> containing embedded NUL bytes with -EINVAL instead of invoking
> undefined behavior.
> 
> Fixes: 60a96a59569b ("Driver core: accept all valid action-strings in uevent-trigger")
> Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
> Reviewed-by: Vishal Moola (Fractile) <vishal.moola@gmail.com>
> ---
> Changes in v3:
> - Document rejection of action strings containing embedded NUL bytes.
> - Correct the Fixes tag.
> - Correct the malformed-input example.
> - Add Vishal Moola's Reviewed-by tag.
> 
>  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
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

  reply	other threads:[~2026-09-20  6:04 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)
2026-09-20  5:37     ` [PATCH v3] " Jiacheng Xu
2026-09-20  6:04       ` Greg KH [this message]
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=2026092014-lumping-datebook-0076@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=rafael@kernel.org \
    --cc=stitch@zju.edu.cn \
    --cc=vishal.moola@gmail.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