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 4.9-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-4.9 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 @@ -128,12 +128,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-4.9/usb-core-hub-fix-race-condition-about-trsmrcy-of-resume.patch queue-4.9/usb-xhci-fix-port-minor-revision.patch queue-4.9/hsr-use-netdev_err-instead-of-warn_once.patch queue-4.9/media-dvbdev-fix-memory-leak-in-dvb_media_device_free.patch queue-4.9/ext4-fix-error-code-in-ext4_commit_super.patch queue-4.9/fotg210-udc-fix-dma-on-ep0-for-length-max-packet-siz.patch queue-4.9/net-usb-ax88179_178a-initialize-local-variables-before-use.patch queue-4.9/mips-reinstate-platform-__div64_32-handler.patch queue-4.9/usb-gadget-pch_udc-check-for-dma-mapping-error.patch queue-4.9/arm64-dts-mt8173-fix-property-typo-of-phys-in-dsi-node.patch queue-4.9/ipw2x00-potential-buffer-overflow-in-libipw_wx_set_encodeext.patch queue-4.9/fddi-defxx-bail-out-gracefully-with-unassigned-pci-resource-for-csr.patch queue-4.9/serial-stm32-fix-incorrect-characters-on-console.patch queue-4.9/sctp-delay-auto_asconf-init-until-binding-the-first-addr.patch queue-4.9/tracing-restructure-trace_clock_global-to-never-block.patch queue-4.9/usb-xhci-increase-timeout-for-hc-halt.patch queue-4.9/s390-disassembler-increase-ebpf-disasm-buffer-size.patch queue-4.9/tracing-use-strlcpy-instead-of-strcpy-in-__trace_find_cmdline.patch queue-4.9/ecryptfs-fix-kernel-panic-with-null-dev_name.patch queue-4.9/revert-337f13046ff0-futex-allow-futex_clock_realtime-with-futex_wait-op.patch queue-4.9/usb-gadget-pch_udc-check-if-driver-is-present-before.patch queue-4.9/bluetooth-verify-amp-hci_chan-before-amp_destroy.patch queue-4.9/usb-fotg210-hcd-fix-an-error-message.patch queue-4.9/dm-rq-fix-double-free-of-blk_mq_tag_set-in-dev-remove-after-table-load-fails.patch queue-4.9/usb-gadget-pch_udc-revert-d3cb25a12138-completely.patch queue-4.9/staging-greybus-uart-fix-unprivileged-tioccserial.patch queue-4.9/squashfs-fix-divide-error-in-calculate_skip.patch queue-4.9/usb-cdc-acm-fix-unprivileged-tioccserial.patch queue-4.9/mips-avoid-handcoded-divu-in-__div64_32-altogether.patch queue-4.9/fotg210-udc-complete-out-requests-on-short-packets.patch queue-4.9/powerpc-64s-fix-crashes-when-toggling-entry-flush-barrier.patch queue-4.9/alsa-hda-realtek-re-order-alc269-sony-quirk-table-entries.patch queue-4.9/usb-gadget-dummy_hcd-fix-gpf-in-gadget_setup.patch queue-4.9/misc-vmw_vmci-explicitly-initialize-vmci_datagram-payload.patch queue-4.9/dm-space-map-common-fix-division-bug-in-sm_ll_find_free_block.patch queue-4.9/dm-ioctl-fix-out-of-bounds-array-access-when-no-devices.patch queue-4.9/alsa-emu8000-fix-a-use-after-free-in-snd_emu8000_create_mixer.patch queue-4.9/alsa-hda-realtek-re-order-alc269-lenovo-quirk-table-entries.patch queue-4.9/staging-rtl8192u-fix-potential-infinite-loop.patch queue-4.9/usb-add-lpm-quirk-for-lenovo-thinkpad-usb-c-dock-gen2-ethernet.patch queue-4.9/platform-x86-thinkpad_acpi-correct-thermal-sensor-allocation.patch queue-4.9/tty-fix-return-value-for-unsupported-ioctls.patch queue-4.9/thermal-core-fair-share-lock-the-thermal-zone-while-looping-over-instances.patch queue-4.9/tracing-map-all-pids-to-command-lines.patch queue-4.9/usb-gadget-fix-double-free-of-device-descriptor-pointers.patch queue-4.9/fotg210-udc-fix-ep0-in-requests-bigger-than-two-pack.patch queue-4.9/fddi-defxx-make-mmio-the-configuration-default-except-for-eisa.patch queue-4.9/iwlwifi-fix-softirq-hardirq-disabling-in-iwl_pcie_enqueue_hcmd.patch queue-4.9/ttyprintk-add-tty-hangup-callback.patch queue-4.9/alsa-hda-realtek-re-order-alc882-sony-quirk-table-entries.patch queue-4.9/fotg210-udc-mask-grp2-interrupts-we-don-t-handle.patch queue-4.9/usb-gadget-r8a66597-add-missing-null-check-on-return.patch queue-4.9/btrfs-fix-metadata-extent-leak-after-failure-to-create-subvolume.patch queue-4.9/staging-wimax-i2400m-fix-byte-order-issue.patch queue-4.9/powerpc-eeh-fix-eeh-handling-for-hugepages-in-ioremap-space.patch queue-4.9/revert-fdt-properly-handle-no-map-field-in-the-memory-region.patch queue-4.9/md-factor-out-a-mddev_find_locked-helper-from-mddev_find.patch queue-4.9/usb-dwc2-fix-gadget-dma-unmap-direction.patch queue-4.9/mmc-core-set-read-only-for-sd-cards-with-permanent-write-protect-bit.patch queue-4.9/alsa-usb-audio-add-midi-quirk-for-vox-tonelab-ex.patch queue-4.9/revert-net-sctp-fix-race-condition-in-sctp_destroy_sock.patch queue-4.9/firmware-qcom-scm-fix-qcom_scm-configuration.patch queue-4.9/ext4-fix-check-to-prevent-false-positive-report-of-incorrect-used-inodes.patch queue-4.9/cfg80211-scan-drop-entry-from-hidden_list-on-overflow.patch queue-4.9/mips-avoid-divu-in-__div64_32-is-result-would-be-zero.patch queue-4.9/tracing-treat-recording-comm-for-idle-task-as-a-success.patch queue-4.9/nfsv4-don-t-discard-segments-marked-for-return-in-_pnfs_return_layout.patch queue-4.9/usb-gadget-uvc-add-binterval-checking-for-hs-mode.patch queue-4.9/mmc-core-do-a-power-cycle-when-the-cmd11-fails.patch queue-4.9/openvswitch-fix-stack-oob-read-while-fragmenting-ipv4-packets.patch queue-4.9/md-cluster-fix-use-after-free-issue-when-removing-rdev.patch queue-4.9/mtd-require-write-permissions-for-locking-and-badblo.patch queue-4.9/fotg210-udc-don-t-dma-more-than-the-buffer-can-take.patch queue-4.9/tty-actually-undefine-superseded-async-flags.patch queue-4.9/usb-dwc3-gadget-ignore-ep-queue-requests-during-bus-.patch queue-4.9/fotg210-udc-remove-a-dubious-condition-leading-to-fo.patch queue-4.9/jffs2-check-the-validity-of-dstlen-in-jffs2_zlib_compress.patch queue-4.9/jffs2-fix-kasan-slab-out-of-bounds-problem.patch queue-4.9/net-nfc-fix-use-after-free-llcp_sock_bind-connect.patch queue-4.9/fbdev-zero-fill-colormap-in-fbcmap.c.patch queue-4.9/ftrace-handle-commands-when-closing-set_ftrace_filter-file.patch queue-4.9/drm-radeon-fix-copy-of-uninitialized-variable-back-to-userspace.patch queue-4.9/powerpc-fix-edeadlock-redefinition-error-in-uapi-asm-errno.h.patch queue-4.9/intel_th-consistency-and-off-by-one-fix.patch queue-4.9/kobject_uevent-remove-warning-in-init_uevent_argv.patch queue-4.9/dm-persistent-data-packed-struct-should-have-an-aligned-attribute-too.patch queue-4.9/kvm-x86-cancel-pvclock_gtod_work-on-module-removal.patch queue-4.9/misc-vmw_vmci-explicitly-initialize-vmci_notify_bm_set_msg-struct.patch queue-4.9/bluetooth-eliminate-the-potential-race-condition-when-removing-the-hci-controller.patch queue-4.9/acpi-custom_method-fix-a-possible-memory-leak.patch queue-4.9/acpi-custom_method-fix-potential-use-after-free-issue.patch queue-4.9/arc-entry-fix-off-by-one-error-in-syscall-number-validation.patch queue-4.9/md-md_open-returns-ebusy-when-entering-racing-area.patch queue-4.9/alsa-sb-fix-two-use-after-free-in-snd_sb_qsound_build.patch queue-4.9/usb-gadget-function-f_fs-string-table-fix-for-multiple-languages.patch queue-4.9/alsa-hda-realtek-remove-redundant-entry-for-alc861-haier-uniwill-devices.patch queue-4.9/usb-gadget-pch_udc-replace-cpu_to_le32-by-lower_32_b.patch queue-4.9/alsa-hda-realtek-re-order-alc882-acer-quirk-table-entries.patch queue-4.9/usb-add-reset-resume-quirk-for-wd19-s-realtek-hub.patch queue-4.9/phy-phy-twl4030-usb-fix-possible-use-after-free-in-t.patch queue-4.9/revert-of-fdt-make-sure-no-map-does-not-remove-already-reserved-regions.patch queue-4.9/misc-lis3lv02d-fix-false-positive-warn-on-various-hp-models.patch