From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> commit 9a71892cbcdb9d1459c84f5a4c722b14354158a5 upstream. This reverts commit 15fffc6a5624b13b428bb1c6e9088e32a55eb82c. This commit causes a regression, so revert it for now until it can come back in a way that works for everyone. Link: https://lore.kernel.org/all/172790598832.1168608.4519484276671503678.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx/ Fixes: 15fffc6a5624 ("driver core: Fix uevent_show() vs driver detach race") Cc: stable <stable@xxxxxxxxxx> Cc: Ashish Sangwan <a.sangwan@xxxxxxxxxxx> Cc: Namjae Jeon <namjae.jeon@xxxxxxxxxxx> Cc: Dirk Behme <dirk.behme@xxxxxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Rafael J. Wysocki <rafael@xxxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/base/core.c | 13 +++++-------- drivers/base/module.c | 4 ---- 2 files changed, 5 insertions(+), 12 deletions(-) --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -24,7 +24,6 @@ #include <linux/mutex.h> #include <linux/pm_runtime.h> #include <linux/netdevice.h> -#include <linux/rcupdate.h> #include <linux/sched/signal.h> #include <linux/sysfs.h> @@ -1138,7 +1137,6 @@ static int dev_uevent(struct kset *kset, struct kobj_uevent_env *env) { struct device *dev = kobj_to_dev(kobj); - struct device_driver *driver; int retval = 0; /* add device node properties if present */ @@ -1167,12 +1165,8 @@ static int dev_uevent(struct kset *kset, if (dev->type && dev->type->name) add_uevent_var(env, "DEVTYPE=%s", dev->type->name); - /* Synchronize with module_remove_driver() */ - rcu_read_lock(); - driver = READ_ONCE(dev->driver); - if (driver) - add_uevent_var(env, "DRIVER=%s", driver->name); - rcu_read_unlock(); + if (dev->driver) + add_uevent_var(env, "DRIVER=%s", dev->driver->name); /* Add common DT information about the device */ of_device_uevent(dev, env); @@ -1242,8 +1236,11 @@ static ssize_t uevent_show(struct device if (!env) return -ENOMEM; + /* Synchronize with really_probe() */ + device_lock(dev); /* let the kset specific function add its keys */ retval = kset->uevent_ops->uevent(kset, &dev->kobj, env); + device_unlock(dev); if (retval) goto out; --- a/drivers/base/module.c +++ b/drivers/base/module.c @@ -7,7 +7,6 @@ #include <linux/errno.h> #include <linux/slab.h> #include <linux/string.h> -#include <linux/rcupdate.h> #include "base.h" static char *make_driver_name(struct device_driver *drv) @@ -78,9 +77,6 @@ void module_remove_driver(struct device_ if (!drv) return; - /* Synchronize with dev_uevent() */ - synchronize_rcu(); - sysfs_remove_link(&drv->p->kobj, "module"); if (drv->owner) Patches currently in stable-queue which might be from gregkh@xxxxxxxxxxxxxxxxxxx are queue-4.19/selftests-vm-remove-call-to-ksft_set_plan.patch queue-4.19/drbd-fix-atomicity-violation-in-drbd_uuid_set_bm.patch queue-4.19/drbd-add-null-check-for-net_conf-to-prevent-dereference-in-state-validation.patch queue-4.19/hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch queue-4.19/ext4-fix-inode-tree-inconsistency-caused-by-enomem.patch queue-4.19/usbip-tools-fix-detach_port-invalid-port-error-path.patch queue-4.19/firmware_loader-block-path-traversal.patch queue-4.19/usb-serial-option-add-support-for-quectel-eg916q-gl.patch queue-4.19/fs-fix-file_set_fowner-lsm-hook-inconsistencies.patch queue-4.19/ocfs2-cancel-dqi_sync_work-before-freeing-oinfo.patch queue-4.19/parisc-fix-64-bit-userspace-syscall-path.patch queue-4.19/acpi-sysfs-validate-return-type-of-_str-method.patch queue-4.19/usb-misc-yurex-fix-race-between-read-and-write.patch queue-4.19/nfs-fix-memory-leak-in-error-path-of-nfs4_do_reclaim.patch queue-4.19/net-ipv6-ensure-we-call-ipv6_mc_down-at-most-once.patch queue-4.19/media-uapi-linux-cec.h-cec_msg_set_reply_to-zero-flags.patch queue-4.19/drm-amd-guard-against-bad-data-for-atif-acpi-method.patch queue-4.19/ext4-fix-incorrect-tid-assumption-in-__jbd2_log_wait_for_space.patch queue-4.19/i2c-xiic-wait-for-tx-empty-to-avoid-missed-tx-naks.patch queue-4.19/bluetooth-btusb-fix-regression-with-fake-csr-controllers-0a12-0001.patch queue-4.19/i2c-isch-add-missed-else.patch queue-4.19/gpio-davinci-fix-lazy-disable.patch queue-4.19/bluetooth-remove-debugfs-directory-on-module-init-failure.patch queue-4.19/ocfs2-remove-unreasonable-unlock-in-ocfs2_read_blocks.patch queue-4.19/vfs-fix-race-between-evice_inodes-and-find_inode-iput.patch queue-4.19/wifi-ath10k-fix-memory-leak-in-management-tx.patch queue-4.19/iio-adc-ti-ads8688-add-missing-select-iio_-triggered_-buffer-in-kconfig.patch queue-4.19/alsa-core-add-isascii-check-to-card-id-generator.patch queue-4.19/revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch queue-4.19/remove-.orig-pattern-from-.gitignore.patch queue-4.19/selftests-kcmp-remove-call-to-ksft_set_plan.patch queue-4.19/kvm-s390-change-virtual-to-physical-address-access-in-diag-0x258-handler.patch queue-4.19/ocfs2-fix-possible-null-ptr-deref-in-ocfs2_set_buffer_uptodate.patch queue-4.19/usb-typec-altmode-should-keep-reference-to-parent.patch queue-4.19/usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch queue-4.19/fat-fix-uninitialized-variable.patch queue-4.19/usb-dwc3-remove-generic-phy-calibrate-calls.patch queue-4.19/iio-magnetometer-ak8975-fix-reading-for-ak099xx-sensors.patch queue-4.19/spi-bcm63xx-fix-module-autoloading.patch queue-4.19/aoe-fix-the-potential-use-after-free-problem-in-more-places.patch queue-4.19/arm64-probes-fix-simulate_ldr-_literal.patch queue-4.19/usb-chipidea-udc-enable-suspend-interrupt-after-usb-.patch queue-4.19/iio-light-opt3001-add-missing-full-scale-range-value.patch queue-4.19/ext4-fix-double-brelse-the-buffer-of-the-extents-path.patch queue-4.19/wifi-iwlegacy-clear-stale-interrupts-before-resuming-device.patch queue-4.19/usb-phy-fix-api-devm_usb_put_phy-can-not-release-the-phy.patch queue-4.19/ext4-propagate-errors-from-ext4_find_extent-in-ext4_insert_range.patch queue-4.19/riscv-define-illegal_pointer_value-for-64bit.patch queue-4.19/xhci-fix-incorrect-stream-context-type-macro.patch queue-4.19/of-irq-support-msi-cells-0-in-of_msi_get_domain.patch queue-4.19/pci-add-function-0-dma-alias-quirk-for-glenfly-arise-chip.patch queue-4.19/arm64-dts-rockchip-override-bios_disable-signal-via-gpio-hog-on-rk3399-puma.patch queue-4.19/ocfs2-reserve-space-for-inline-xattr-before-attaching-reflink-tree.patch queue-4.19/ext4-aovid-use-after-free-in-ext4_ext_insert_extent.patch queue-4.19/clk-fix-pointer-casting-to-prevent-oops-in-devm_clk_release.patch queue-4.19/hv_netvsc-fix-vf-namespace-also-in-synthetic-nic-netdev_register-event.patch queue-4.19/usb-misc-cypress_cy7c63-check-for-short-transfer.patch queue-4.19/revert-driver-core-fix-uevent_show-vs-driver-detach-race.patch queue-4.19/cdc-ncm-avoid-overflow-in-sanity-checking.patch queue-4.19/posix-clock-fix-missing-timespec64-check-in-pc_clock_settime.patch queue-4.19/wifi-mac80211-do-not-pass-a-stopped-vif-to-the-driver-in-.get_txpower.patch queue-4.19/ocfs2-fix-null-ptr-deref-when-journal-load-failed.patch queue-4.19/x86-cpufeatures-define-x86_feature_amd_ibpb_ret.patch queue-4.19/kvm-fix-a-data-race-on-last_boosted_vcpu-in-kvm_vcpu_on_spin.patch queue-4.19/pps-add-an-error-check-in-parport_attach.patch queue-4.19/ext4-fix-incorrect-tid-assumption-in-ext4_wait_for_tail_page_commit.patch queue-4.19/usb-yurex-replace-snprintf-with-the-safer-scnprintf-.patch queue-4.19/arm64-uprobes-change-the-uprobe_opcode_t-typedef-to-fix-the-sparse-warning.patch queue-4.19/x86-apic-always-explicitly-disarm-tsc-deadline-timer.patch queue-4.19/soc-versatile-integrator-fix-of-node-leak-in-probe-error-path.patch queue-4.19/f2fs-avoid-potential-int-overflow-in-sanity_check_area_boundary.patch queue-4.19/ocfs2-fix-the-la-space-leak-when-unmounting-an-ocfs2-volume.patch queue-4.19/f2fs-prevent-possible-int-overflow-in-dir_block_index.patch queue-4.19/usb-appledisplay-close-race-between-probe-and-completion-handler.patch queue-4.19/alsa-usb-audio-add-quirks-for-dell-wd19-dock.patch queue-4.19/nilfs2-fix-potential-deadlock-with-newly-created-symlinks.patch queue-4.19/parport-proper-fix-for-array-out-of-bounds-access.patch queue-4.19/usb-dwc3-core-stop-processing-of-pending-events-if-c.patch queue-4.19/arm64-probes-remove-broken-ldr-literal-uprobe-support.patch queue-4.19/usb-serial-option-add-telit-fn920c04-mbim-compositions.patch queue-4.19/btrfs-wait-for-fixup-workers-before-stopping-cleaner-kthread-during-umount.patch queue-4.19/jbd2-stop-waiting-for-space-when-jbd2_cleanup_journal_tail-returns-error.patch queue-4.19/iio-hid-sensors-fix-an-error-handling-path-in-_hid_sensor_set_report_latency.patch queue-4.19/drm-vmwgfx-handle-surface-check-failure-correctly.patch queue-4.19/parisc-fix-itlb-miss-handler-for-64-bit-programs.patch queue-4.19/s390-sclp_vt220-convert-newlines-to-crlf-instead-of-lfcr.patch queue-4.19/xz-cleanup-crc32-edits-from-2018.patch queue-4.19/soundwire-stream-revert-soundwire-stream-fix-programming-slave-ports-for-non-continous-port-maps.patch queue-4.19/net-fix-an-unsafe-loop-on-the-list.patch queue-4.19/nilfs2-fix-kernel-bug-due-to-missing-clearing-of-buffer-delay-flag.patch queue-4.19/crypto-aead-cipher-zeroize-key-buffer-after-use.patch queue-4.19/media-venus-fix-use-after-free-bug-in-venus_remove-due-to-race-condition.patch queue-4.19/usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch queue-4.19/clk-rockchip-fix-error-for-unknown-clocks.patch queue-4.19/tty-rp2-fix-reset-with-non-forgiving-pcie-host-bridges.patch queue-4.19/iio-dac-stm32-dac-core-add-missing-select-regmap_mmio-in-kconfig.patch queue-4.19/pps-remove-usage-of-the-deprecated-ida_simple_xx-api.patch queue-4.19/xhci-fix-link-trb-dma-in-command-ring-stopped-completion-event.patch queue-4.19/clk-fix-slab-out-of-bounds-error-in-devm_clk_release.patch queue-4.19/gpio-prevent-potential-speculation-leaks-in-gpio_device_get_desc.patch queue-4.19/ocfs2-fix-uninit-value-in-ocfs2_get_block.patch queue-4.19/nilfs2-propagate-directory-read-errors-from-nilfs_find_entry.patch queue-4.19/acpi-button-add-dmi-quirk-for-samsung-galaxy-book2-to-fix-initial-lid-detection-issue.patch queue-4.19/i2c-aspeed-update-the-stop-sw-state-when-the-bus-recovery-occurs.patch queue-4.19/driver-core-bus-return-eio-instead-of-0-when-show-st.patch queue-4.19/input-adp5589-keys-fix-adp5589_gpio_get_value.patch queue-4.19/tomoyo-fallback-to-realpath-if-symlink-s-pathname-does-not-exist.patch queue-4.19/ext4-no-need-to-continue-when-the-number-of-entries-is-1.patch queue-4.19/usb-serial-pl2303-add-device-id-for-macrosilicon-ms3020.patch queue-4.19/perf-core-fix-small-negative-period-being-ignored.patch queue-4.19/net-dsa-mv88e6xxx-fix-out-of-bound-access.patch queue-4.19/usb-yurex-fix-inconsistent-locking-bug-in-yurex_read.patch