aboutsummaryrefslogtreecommitdiffstats
diff options
-rw-r--r--0001-kobject_uevent-remove-warning-in-init_uevent_argv.patch39
-rw-r--r--series1
2 files changed, 40 insertions, 0 deletions
diff --git a/0001-kobject_uevent-remove-warning-in-init_uevent_argv.patch b/0001-kobject_uevent-remove-warning-in-init_uevent_argv.patch
new file mode 100644
index 00000000000000..d284c73c14bf08
--- /dev/null
+++ b/0001-kobject_uevent-remove-warning-in-init_uevent_argv.patch
@@ -0,0 +1,39 @@
+From f5325c6ed20f75bbd22cd467486ca5a28c3dd73c Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Mon, 5 Apr 2021 11:45:50 +0200
+Subject: [PATCH] kobject_uevent: remove warning in init_uevent_argv()
+
+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/20201107082206.GA19079@kroah.com
+Reported-by: syzbot+92340f7b2b4789907fdb@syzkaller.appspotmail.com
+Cc: "Rafael J. Wysocki" <rafael@kernel.org>
+Cc: linux-kernel@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ lib/kobject_uevent.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+--- a/lib/kobject_uevent.c
++++ b/lib/kobject_uevent.c
+@@ -251,12 +251,13 @@ static int kobj_usermode_filter(struct k
+
+ 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;
+ }
+
diff --git a/series b/series
index 650e0af1418f4e..595845056d2364 100644
--- a/series
+++ b/series
@@ -1,4 +1,5 @@
#
+0001-kobject_uevent-remove-warning-in-init_uevent_argv.patch
0001-Kbuild-provide-a-common-kernel-installation-script.patch
0001-x86-tools-relocs-add-__printf-attribute-to-die.patch
0001-driver-core-aux-test-code.patch