This is a note to let you know that I've just added the patch titled kobject_uevent: remove warning in init_uevent_argv() to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: kobject_uevent-remove-warning-in-init_uevent_argv.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From b4104180a2efb85f55e1ba1407885c9421970338 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Date: Mon, 5 Apr 2021 11:48:52 +0200 Subject: kobject_uevent: remove warning in init_uevent_argv() From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> commit b4104180a2efb85f55e1ba1407885c9421970338 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/20201107082206.GA19079@xxxxxxxxx Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> Cc: linux-kernel@xxxxxxxxxxxxxxx Reported-by: syzbot+92340f7b2b4789907fdb@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20210405094852.1348499-1-gregkh@xxxxxxxxxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- 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; } Patches currently in stable-queue which might be from gregkh@xxxxxxxxxxxxxxxxxxx are queue-5.4/cdc-wdm-untangle-a-circular-dependency-between-callback-and-softint.patch queue-5.4/usb-core-hub-fix-race-condition-about-trsmrcy-of-resume.patch queue-5.4/usb-typec-tcpm-fix-error-while-calculating-pps-out-values.patch queue-5.4/hfsplus-prevent-corruption-in-shrinking-truncate.patch queue-5.4/powerpc-64s-fix-crashes-when-toggling-stf-barrier.patch queue-5.4/pm-runtime-fix-unpaired-parent-child_count-for-force_resume.patch queue-5.4/mips-reinstate-platform-__div64_32-handler.patch queue-5.4/usb-dwc3-omap-improve-extcon-initialization.patch queue-5.4/tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch queue-5.4/tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch queue-5.4/arc-mm-pae-use-40-bit-physical-page-mask.patch queue-5.4/usb-xhci-increase-timeout-for-hc-halt.patch queue-5.4/usb-fotg210-hcd-fix-an-error-message.patch queue-5.4/squashfs-fix-divide-error-in-calculate_skip.patch queue-5.4/mips-avoid-handcoded-divu-in-__div64_32-altogether.patch queue-5.4/powerpc-64s-fix-crashes-when-toggling-entry-flush-barrier.patch queue-5.4/arm-9020-1-mm-use-correct-section-size-macro-to-describe-the-fdt-virtual-address.patch queue-5.4/drm-radeon-dpm-disable-sclk-switching-on-oland-when-two-4k-60hz-monitors-are-connected.patch queue-5.4/drm-i915-avoid-div-by-zero-on-gen2.patch queue-5.4/thermal-core-fair-share-lock-the-thermal-zone-while-looping-over-instances.patch queue-5.4/fddi-defxx-make-mmio-the-configuration-default-except-for-eisa.patch queue-5.4/f2fs-fix-error-handling-in-f2fs_end_enable_verity.patch queue-5.4/xhci-add-reset-resume-quirk-for-amd-xhci-controller.patch queue-5.4/mm-hugetlb-fix-f_seal_future_write.patch queue-5.4/arm-9011-1-centralize-phys-to-virt-conversion-of-dt-atags-address.patch queue-5.4/arm-9027-1-head.s-explicitly-map-dt-even-if-it-lives-in-the-first-physical-section.patch queue-5.4/tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch queue-5.4/usb-dwc2-fix-gadget-dma-unmap-direction.patch queue-5.4/iio-tsl2583-fix-division-by-a-zero-lux_val.patch queue-5.4/arm-9012-1-move-device-tree-mapping-out-of-linear-region.patch queue-5.4/kvm-x86-mmu-remove-the-defunct-update_pte-paging-hook.patch queue-5.4/iomap-fix-sub-page-uptodate-handling.patch queue-5.4/usb-dwc3-pci-enable-usb2-gadget-lpm-disable-for-intel-merrifield.patch queue-5.4/iio-gyro-mpu3050-fix-reported-temperature-value.patch queue-5.4/usb-dwc3-gadget-return-success-always-for-kick-transfer-in-ep-queue.patch queue-5.4/mips-avoid-divu-in-__div64_32-is-result-would-be-zero.patch queue-5.4/xhci-do-not-use-gfp_kernel-in-potentially-atomic-context.patch queue-5.4/kobject_uevent-remove-warning-in-init_uevent_argv.patch queue-5.4/kvm-x86-cancel-pvclock_gtod_work-on-module-removal.patch queue-5.4/mm-fix-struct-page-layout-on-32-bit-systems.patch queue-5.4/arc-entry-fix-off-by-one-error-in-syscall-number-validation.patch queue-5.4/userfaultfd-release-page-in-error-path-to-avoid-bug_on.patch