Skip to content

Commit

Permalink
kobject_uevent: remove warning in init_uevent_argv()
Browse files Browse the repository at this point in the history
commit b410418 upstream.

syzbot can trigger the WARN() in init_uevent_argv() which isn't the
nicest as the code does properly recover and handle the error.  So
change the WARN() call to pr_warn() and provide some more information on
what the buffer size that was needed.

Link: https://lore.kernel.org/r/[email protected]
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: [email protected]
Reported-by: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed May 19, 2021
1 parent 658e898 commit fb80624
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/kobject_uevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,13 @@ static int kobj_usermode_filter(struct kobject *kobj)

static int init_uevent_argv(struct kobj_uevent_env *env, const char *subsystem)
{
int buffer_size = sizeof(env->buf) - env->buflen;
int len;

len = strlcpy(&env->buf[env->buflen], subsystem,
sizeof(env->buf) - env->buflen);
if (len >= (sizeof(env->buf) - env->buflen)) {
WARN(1, KERN_ERR "init_uevent_argv: buffer size too small\n");
len = strlcpy(&env->buf[env->buflen], subsystem, buffer_size);
if (len >= buffer_size) {
pr_warn("init_uevent_argv: buffer size of %d too small, needed %d\n",
buffer_size, len);
return -ENOMEM;
}

Expand Down

0 comments on commit fb80624

Please sign in to comment.