* [PATCH] kobject: fix out-of-bounds read in action parser
@ 2026-08-18 6:26 Jiacheng Xu
2026-08-24 17:32 ` Vishal Moola (Fractile)
0 siblings, 1 reply; 13+ messages in thread
From: Jiacheng Xu @ 2026-08-18 6:26 UTC (permalink / raw)
To: gregkh, rafael, dakr; +Cc: akpm, driver-core
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.
Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
---
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;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] kobject: fix out-of-bounds read in action parser
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
0 siblings, 2 replies; 13+ messages in thread
From: Vishal Moola (Fractile) @ 2026-08-24 17:32 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: gregkh, rafael, dakr, akpm, driver-core
I was looking at reviewing your patch. Unfortunately, it doesn't appear
to apply cleanly; I'm seeing:
Applying: kobject: fix out-of-bounds read in action parser
error: corrupt patch at .git/rebase-apply/patch:10
Patch failed at 0001 kobject: fix out-of-bounds read in action parser
It looks like sashiko failed to apply it as well[1]. Perhaps you should
reformat and resend?
On Tue, Aug 18, 2026 at 02:26:14PM +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.
>
> Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
> Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
> ---
> 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;
[1] https://sashiko.dev/#/patchset/200d27f7.1471a.1a0138c92da.Coremail.stitch%40zju.edu.cn
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Re: [PATCH] kobject: fix out-of-bounds read in action parser
2026-08-24 17:32 ` Vishal Moola (Fractile)
@ 2026-08-25 3:54 ` Jiacheng Xu
2026-08-25 3:57 ` [PATCH v2] " Jiacheng Xu
1 sibling, 0 replies; 13+ messages in thread
From: Jiacheng Xu @ 2026-08-25 3:54 UTC (permalink / raw)
To: Vishal Moola (Fractile); +Cc: gregkh, rafael, dakr, akpm, driver-core
Thanks for pointing this out. I'll reformat and resend the patch as v2. Sorry for the noise.
> -----原始邮件-----
> 发件人: "Vishal Moola (Fractile)" <vishal.moola@gmail.com>
> 发送时间:2026-08-25 01:32:54 (星期二)
> 收件人: "Jiacheng Xu" <stitch@zju.edu.cn>
> 抄送: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, akpm@linux-foundation.org, driver-core@lists.linux.dev
> 主题: Re: [PATCH] kobject: fix out-of-bounds read in action parser
>
> I was looking at reviewing your patch. Unfortunately, it doesn't appear
> to apply cleanly; I'm seeing:
>
> Applying: kobject: fix out-of-bounds read in action parser
> error: corrupt patch at .git/rebase-apply/patch:10
> Patch failed at 0001 kobject: fix out-of-bounds read in action parser
>
> It looks like sashiko failed to apply it as well[1]. Perhaps you should
> reformat and resend?
>
> On Tue, Aug 18, 2026 at 02:26:14PM +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.
> >
> > Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
> > Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
> > ---
> > 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;
>
> [1] https://sashiko.dev/#/patchset/200d27f7.1471a.1a0138c92da.Coremail.stitch%40zju.edu.cn
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] kobject: fix out-of-bounds read in action parser
2026-08-24 17:32 ` Vishal Moola (Fractile)
2026-08-25 3:54 ` Jiacheng Xu
@ 2026-08-25 3:57 ` Jiacheng Xu
2026-08-25 5:33 ` Greg KH
2026-09-20 5:37 ` [PATCH v3] " Jiacheng Xu
1 sibling, 2 replies; 13+ messages in thread
From: Jiacheng Xu @ 2026-08-25 3:57 UTC (permalink / raw)
To: Vishal Moola (Fractile); +Cc: gregkh, rafael, dakr, akpm, driver-core
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.
Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
---
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
> -----原始邮件-----
> 发件人: "Vishal Moola (Fractile)" <vishal.moola@gmail.com>
> 发送时间:2026-08-25 01:32:54 (星期二)
> 收件人: "Jiacheng Xu" <stitch@zju.edu.cn>
> 抄送: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, akpm@linux-foundation.org, driver-core@lists.linux.dev
> 主题: Re: [PATCH] kobject: fix out-of-bounds read in action parser
>
> I was looking at reviewing your patch. Unfortunately, it doesn't appear
> to apply cleanly; I'm seeing:
>
> Applying: kobject: fix out-of-bounds read in action parser
> error: corrupt patch at .git/rebase-apply/patch:10
> Patch failed at 0001 kobject: fix out-of-bounds read in action parser
>
> It looks like sashiko failed to apply it as well[1]. Perhaps you should
> reformat and resend?
>
> On Tue, Aug 18, 2026 at 02:26:14PM +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.
> >
> > Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
> > Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
> > ---
> > 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;
>
> [1] https://sashiko.dev/#/patchset/200d27f7.1471a.1a0138c92da.Coremail.stitch%40zju.edu.cn
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2] kobject: fix out-of-bounds read in action parser
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 7:05 ` [PATCH v2 RESEND] kobject: fix out-of-bounds access in kobject_action_type() Jiacheng Xu
2026-09-20 5:37 ` [PATCH v3] " Jiacheng Xu
1 sibling, 2 replies; 13+ messages in thread
From: Greg KH @ 2026-08-25 5:33 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: Vishal Moola (Fractile), rafael, dakr, akpm, driver-core
On Tue, Aug 25, 2026 at 11:57:39AM +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.
<snip>
This is being sent in base64, and the tools can not apply it :(
Please fix your email client to not compress/encode the message.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] kobject: fix out-of-bounds read in action parser
2026-08-25 5:33 ` Greg KH
@ 2026-08-25 6:26 ` 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
1 sibling, 1 reply; 13+ messages in thread
From: Jiacheng Xu @ 2026-08-25 6:26 UTC (permalink / raw)
To: gregkh; +Cc: vishal.moola, rafael, dakr, akpm, driver-core, Jiacheng Xu
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.
Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] kobject: fix out-of-bounds read in action parser
2026-08-25 6:26 ` [PATCH] " Jiacheng Xu
@ 2026-08-25 6:46 ` Greg KH
0 siblings, 0 replies; 13+ messages in thread
From: Greg KH @ 2026-08-25 6:46 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: vishal.moola, rafael, dakr, akpm, driver-core
On Tue, Aug 25, 2026 at 02:26:20PM +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.
>
> Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
> Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
> ---
> 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:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for what
needs to be done here to properly describe 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 RESEND] kobject: fix out-of-bounds access in kobject_action_type()
2026-08-25 5:33 ` Greg KH
2026-08-25 6:26 ` [PATCH] " Jiacheng Xu
@ 2026-08-25 7:05 ` Jiacheng Xu
2026-08-25 7:35 ` Greg KH
2026-08-25 12:12 ` Vishal Moola (Fractile)
1 sibling, 2 replies; 13+ messages in thread
From: Jiacheng Xu @ 2026-08-25 7:05 UTC (permalink / raw)
To: gregkh; +Cc: vishal.moola, rafael, dakr, akpm, driver-core, Jiacheng Xu
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.
Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 RESEND] kobject: fix out-of-bounds access in kobject_action_type()
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)
1 sibling, 0 replies; 13+ messages in thread
From: Greg KH @ 2026-08-25 7:35 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: vishal.moola, rafael, dakr, akpm, driver-core
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.
>
> Fixes: f36776fafbaa ("kobject: support passing in variables for synthetic uevents")
> Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
> ---
> 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:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for what
needs to be done here to properly describe 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 RESEND] kobject: fix out-of-bounds access in kobject_action_type()
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)
1 sibling, 0 replies; 13+ messages in thread
From: Vishal Moola (Fractile) @ 2026-08-25 12:12 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: gregkh, rafael, dakr, akpm, driver-core
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
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3] kobject: fix out-of-bounds access in kobject_action_type()
2026-08-25 3:57 ` [PATCH v2] " Jiacheng Xu
2026-08-25 5:33 ` Greg KH
@ 2026-09-20 5:37 ` Jiacheng Xu
2026-09-20 6:04 ` Greg KH
2026-09-24 18:46 ` Danilo Krummrich
1 sibling, 2 replies; 13+ messages in thread
From: Jiacheng Xu @ 2026-09-20 5:37 UTC (permalink / raw)
To: gregkh; +Cc: vishal.moola, rafael, dakr, akpm, driver-core, Jiacheng Xu
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3] kobject: fix out-of-bounds access in kobject_action_type()
2026-09-20 5:37 ` [PATCH v3] " Jiacheng Xu
@ 2026-09-20 6:04 ` Greg KH
2026-09-24 18:46 ` Danilo Krummrich
1 sibling, 0 replies; 13+ messages in thread
From: Greg KH @ 2026-09-20 6:04 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: vishal.moola, rafael, dakr, akpm, driver-core
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] kobject: fix out-of-bounds access in kobject_action_type()
2026-09-20 5:37 ` [PATCH v3] " Jiacheng Xu
2026-09-20 6:04 ` Greg KH
@ 2026-09-24 18:46 ` Danilo Krummrich
1 sibling, 0 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-24 18:46 UTC (permalink / raw)
To: Jiacheng Xu; +Cc: gregkh, vishal.moola, rafael, dakr, akpm, driver-core
On Sun, 20 Sep 2026 13:37:26 +0800, Jiacheng Xu wrote:
> [PATCH v3] kobject: fix out-of-bounds access in kobject_action_type()
Applied, thanks!
Branch: driver-core-testing
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
[1/1] kobject: fix out-of-bounds access in kobject_action_type()
commit: d516455c9405
The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).
The patch is in the driver-core-testing branch and will be promoted to
driver-core-next after validation.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-09-24 18:46 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-09-24 18:46 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox