Skip to content

Commit 1ea5cdd

Browse files
committed
kobject_uevent: remove warning in init_uevent_argv()
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]>
1 parent 6e088a8 commit 1ea5cdd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/kobject_uevent.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,13 @@ static int kobj_usermode_filter(struct kobject *kobj)
250250

251251
static int init_uevent_argv(struct kobj_uevent_env *env, const char *subsystem)
252252
{
253+
int buffer_size = sizeof(env->buf) - env->buflen;
253254
int len;
254255

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

0 commit comments

Comments
 (0)