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.12-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.12 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.12/cdc-wdm-untangle-a-circular-dependency-between-callback-and-softint.patch queue-5.12/btrfs-zoned-sanity-check-zone-type.patch queue-5.12/usb-core-hub-fix-race-condition-about-trsmrcy-of-resume.patch queue-5.12/usb-typec-tcpm-fix-error-while-calculating-pps-out-values.patch queue-5.12/kasan-fix-unit-tests-with-config_ubsan_local_bounds-enabled.patch queue-5.12/hfsplus-prevent-corruption-in-shrinking-truncate.patch queue-5.12/powerpc-64s-fix-crashes-when-toggling-stf-barrier.patch queue-5.12/kvm-vmx-disable-preemption-when-probing-user-return-msrs.patch queue-5.12/pm-runtime-fix-unpaired-parent-child_count-for-force_resume.patch queue-5.12/kernel-resource-make-walk_system_ram_res-find-all-bu.patch queue-5.12/mips-reinstate-platform-__div64_32-handler.patch queue-5.12/cpufreq-intel_pstate-use-hwp-if-enabled-by-platform-firmware.patch queue-5.12/mm-hugetlb-fix-cow-where-page-writtable-in-child.patch queue-5.12/xen-gntdev-fix-gntdev_mmap-error-exit-path.patch queue-5.12/xhci-pci-allow-host-runtime-pm-as-default-for-intel-alder-lake-xhci.patch queue-5.12/btrfs-zoned-fix-silent-data-loss-after-failure-splitting-ordered-extent.patch queue-5.12/usb-typec-tcpm-fix-wrong-handling-for-not_supported-.patch queue-5.12/usb-dwc3-omap-improve-extcon-initialization.patch queue-5.12/tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch queue-5.12/tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch queue-5.12/arc-mm-pae-use-40-bit-physical-page-mask.patch queue-5.12/arm64-mte-initialize-rgsr_el1.seed-in-__cpu_setup.patch queue-5.12/usb-xhci-increase-timeout-for-hc-halt.patch queue-5.12/acpi-pm-add-acpi-id-of-alder-lake-fan.patch queue-5.12/usb-fotg210-hcd-fix-an-error-message.patch queue-5.12/kvm-svm-make-sure-ghcb-is-mapped-before-updating.patch queue-5.12/btrfs-fix-unmountable-seed-device-after-fstrim.patch queue-5.12/kvm-vmx-do-not-advertise-rdpid-if-enable_rdtscp-control-is-unsupported.patch queue-5.12/squashfs-fix-divide-error-in-calculate_skip.patch queue-5.12/arm64-fix-race-condition-on-pg_dcache_clean-in-__sync_icache_dcache.patch queue-5.12/usb-dwc3-gadget-enable-suspend-events.patch queue-5.12/mips-avoid-handcoded-divu-in-__div64_32-altogether.patch queue-5.12/powerpc-64s-fix-crashes-when-toggling-entry-flush-barrier.patch queue-5.12/usb-dwc3-gadget-free-gadget-structure-only-after-fre.patch queue-5.12/drm-radeon-dpm-disable-sclk-switching-on-oland-when-two-4k-60hz-monitors-are-connected.patch queue-5.12/alarmtimer-check-rtc-features-instead-of-ops.patch queue-5.12/drm-i915-avoid-div-by-zero-on-gen2.patch queue-5.12/kvm-cap-halt-polling-at-kvm-max_halt_poll_ns.patch queue-5.12/xhci-add-reset-resume-quirk-for-amd-xhci-controller.patch queue-5.12/mm-hugetlb-fix-f_seal_future_write.patch queue-5.12/sh-remove-unused-variable.patch queue-5.12/usb-typec-tcpm-fix-wrong-handling-in-get_sink_cap.patch queue-5.12/btrfs-initialize-return-variable-in-cleanup_free_space_cache_v1.patch queue-5.12/arc-mm-use-max_high_pfn-as-a-highmem-zone-border.patch queue-5.12/tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch queue-5.12/iio-core-fix-ioctl-handlers-removal.patch queue-5.12/usb-dwc2-fix-gadget-dma-unmap-direction.patch queue-5.12/xhci-fix-giving-back-cancelled-urbs-even-if-halted-endpoint-can-t-reset.patch queue-5.12/kvm-vmx-invoke-nmi-non-ist-entry-instead-of-ist-entry.patch queue-5.12/x86-sched-fix-the-amd-cppc-maximum-performance-value-on-certain-amd-ryzen-generations.patch queue-5.12/iio-tsl2583-fix-division-by-a-zero-lux_val.patch queue-5.12/kernel-resource-make-walk_mem_res-find-all-busy-iore.patch queue-5.12/blk-iocost-fix-weight-updates-of-inner-active-iocgs.patch queue-5.12/usb-typec-ucsi-retrieve-all-the-pdos-instead-of-just-the-first-4.patch queue-5.12/usb-typec-ucsi-put-fwnode-in-any-case-during-probe.patch queue-5.12/usb-dwc3-pci-enable-usb2-gadget-lpm-disable-for-intel-merrifield.patch queue-5.12/kvm-nvmx-always-make-an-attempt-to-map-evmcs-after-migration.patch queue-5.12/iio-gyro-mpu3050-fix-reported-temperature-value.patch queue-5.12/usb-musb-fix-an-error-message.patch queue-5.12/usb-dwc3-gadget-return-success-always-for-kick-transfer-in-ep-queue.patch queue-5.12/mips-avoid-divu-in-__div64_32-is-result-would-be-zero.patch queue-5.12/btrfs-fix-deadlock-when-cloning-inline-extents-and-using-qgroups.patch queue-5.12/clocksource-drivers-timer-ti-dm-prepare-to-handle-dra7-timer-wrap-issue.patch queue-5.12/kvm-exit-halt-polling-on-need_resched-as-well.patch queue-5.12/btrfs-fix-race-leading-to-unpersisted-data-and-metadata-on-fsync.patch queue-5.12/xhci-do-not-use-gfp_kernel-in-potentially-atomic-context.patch queue-5.12/kvm-x86-add-support-for-rdpid-without-rdtscp.patch queue-5.12/usb-dwc3-imx8mp-fix-error-return-code-in-dwc3_imx8mp_probe.patch queue-5.12/drm-i915-dp-use-slow-and-wide-link-training-for-everything.patch queue-5.12/kobject_uevent-remove-warning-in-init_uevent_argv.patch queue-5.12/drm-amd-display-initialize-attribute-for-hdcp_srm-sysfs-file.patch queue-5.12/kvm-x86-move-rdpid-emulation-intercept-to-its-own-enum.patch queue-5.12/clocksource-drivers-timer-ti-dm-handle-dra7-timer-wrap-errata-i940.patch queue-5.12/mm-fix-struct-page-layout-on-32-bit-systems.patch queue-5.12/arc-entry-fix-off-by-one-error-in-syscall-number-validation.patch queue-5.12/userfaultfd-release-page-in-error-path-to-avoid-bug_on.patch queue-5.12/keys-trusted-fix-memory-leak-on-object-td.patch queue-5.12/kvm-x86-emulate-rdpid-only-if-rdtscp-is-supported.patch