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.10-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.10 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.10/cdc-wdm-untangle-a-circular-dependency-between-callback-and-softint.patch queue-5.10/usb-core-hub-fix-race-condition-about-trsmrcy-of-resume.patch queue-5.10/usb-typec-tcpm-fix-error-while-calculating-pps-out-values.patch queue-5.10/iommu-vt-d-remove-wo-permissions-on-second-level-paging-entries.patch queue-5.10/kasan-fix-unit-tests-with-config_ubsan_local_bounds-enabled.patch queue-5.10/hfsplus-prevent-corruption-in-shrinking-truncate.patch queue-5.10/powerpc-64s-fix-crashes-when-toggling-stf-barrier.patch queue-5.10/kvm-vmx-disable-preemption-when-probing-user-return-msrs.patch queue-5.10/pm-runtime-fix-unpaired-parent-child_count-for-force_resume.patch queue-5.10/kernel-resource-make-walk_system_ram_res-find-all-bu.patch queue-5.10/mips-reinstate-platform-__div64_32-handler.patch queue-5.10/cpufreq-intel_pstate-use-hwp-if-enabled-by-platform-firmware.patch queue-5.10/xen-gntdev-fix-gntdev_mmap-error-exit-path.patch queue-5.10/xhci-pci-allow-host-runtime-pm-as-default-for-intel-alder-lake-xhci.patch queue-5.10/usb-dwc3-omap-improve-extcon-initialization.patch queue-5.10/revert-iommu-vt-d-remove-wo-permissions-on-second-level.patch queue-5.10/tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch queue-5.10/tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch queue-5.10/arc-mm-pae-use-40-bit-physical-page-mask.patch queue-5.10/arm64-mte-initialize-rgsr_el1.seed-in-__cpu_setup.patch queue-5.10/usb-xhci-increase-timeout-for-hc-halt.patch queue-5.10/acpi-pm-add-acpi-id-of-alder-lake-fan.patch queue-5.10/usb-fotg210-hcd-fix-an-error-message.patch queue-5.10/kvm-vmx-do-not-advertise-rdpid-if-enable_rdtscp-control-is-unsupported.patch queue-5.10/squashfs-fix-divide-error-in-calculate_skip.patch queue-5.10/arm64-fix-race-condition-on-pg_dcache_clean-in-__sync_icache_dcache.patch queue-5.10/usb-dwc3-gadget-enable-suspend-events.patch queue-5.10/mips-avoid-handcoded-divu-in-__div64_32-altogether.patch queue-5.10/powerpc-64s-fix-crashes-when-toggling-entry-flush-barrier.patch queue-5.10/usb-dwc3-gadget-free-gadget-structure-only-after-fre.patch queue-5.10/arm-9020-1-mm-use-correct-section-size-macro-to-describe-the-fdt-virtual-address.patch queue-5.10/drm-radeon-dpm-disable-sclk-switching-on-oland-when-two-4k-60hz-monitors-are-connected.patch queue-5.10/drm-i915-avoid-div-by-zero-on-gen2.patch queue-5.10/kvm-cap-halt-polling-at-kvm-max_halt_poll_ns.patch queue-5.10/xhci-add-reset-resume-quirk-for-amd-xhci-controller.patch queue-5.10/mm-hugetlb-fix-f_seal_future_write.patch queue-5.10/arm-9011-1-centralize-phys-to-virt-conversion-of-dt-atags-address.patch queue-5.10/arm-9027-1-head.s-explicitly-map-dt-even-if-it-lives-in-the-first-physical-section.patch queue-5.10/arc-mm-use-max_high_pfn-as-a-highmem-zone-border.patch queue-5.10/tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch queue-5.10/usb-dwc2-fix-gadget-dma-unmap-direction.patch queue-5.10/kvm-vmx-invoke-nmi-non-ist-entry-instead-of-ist-entry.patch queue-5.10/iio-tsl2583-fix-division-by-a-zero-lux_val.patch queue-5.10/kernel-resource-make-walk_mem_res-find-all-busy-iore.patch queue-5.10/arm-9012-1-move-device-tree-mapping-out-of-linear-region.patch queue-5.10/blk-iocost-fix-weight-updates-of-inner-active-iocgs.patch queue-5.10/kvm-x86-mmu-remove-the-defunct-update_pte-paging-hook.patch queue-5.10/usb-typec-ucsi-retrieve-all-the-pdos-instead-of-just-the-first-4.patch queue-5.10/usb-typec-ucsi-put-fwnode-in-any-case-during-probe.patch queue-5.10/usb-dwc3-pci-enable-usb2-gadget-lpm-disable-for-intel-merrifield.patch queue-5.10/kvm-nvmx-always-make-an-attempt-to-map-evmcs-after-migration.patch queue-5.10/iio-gyro-mpu3050-fix-reported-temperature-value.patch queue-5.10/usb-musb-fix-an-error-message.patch queue-5.10/usb-dwc3-gadget-return-success-always-for-kick-transfer-in-ep-queue.patch queue-5.10/mips-avoid-divu-in-__div64_32-is-result-would-be-zero.patch queue-5.10/clocksource-drivers-timer-ti-dm-prepare-to-handle-dra7-timer-wrap-issue.patch queue-5.10/revert-iommu-vt-d-preset-access-dirty-bits-for-iova.patch queue-5.10/kvm-exit-halt-polling-on-need_resched-as-well.patch queue-5.10/btrfs-fix-race-leading-to-unpersisted-data-and-metadata-on-fsync.patch queue-5.10/iommu-vt-d-preset-access-dirty-bits-for-iova-over-fl.patch queue-5.10/xhci-do-not-use-gfp_kernel-in-potentially-atomic-context.patch queue-5.10/kobject_uevent-remove-warning-in-init_uevent_argv.patch queue-5.10/drm-amd-display-initialize-attribute-for-hdcp_srm-sysfs-file.patch queue-5.10/kvm-x86-move-rdpid-emulation-intercept-to-its-own-enum.patch queue-5.10/clocksource-drivers-timer-ti-dm-handle-dra7-timer-wrap-errata-i940.patch queue-5.10/mm-fix-struct-page-layout-on-32-bit-systems.patch queue-5.10/arc-entry-fix-off-by-one-error-in-syscall-number-validation.patch queue-5.10/userfaultfd-release-page-in-error-path-to-avoid-bug_on.patch queue-5.10/keys-trusted-fix-memory-leak-on-object-td.patch queue-5.10/kvm-x86-emulate-rdpid-only-if-rdtscp-is-supported.patch