linux-stable/drivers/base
Benjamin Herrenschmidt 50091945a6 drivers: core: Remove glue dirs from sysfs earlier
commit 726e410979 upstream.

For devices with a class, we create a "glue" directory between
the parent device and the new device with the class name.

This directory is never "explicitely" removed when empty however,
this is left to the implicit sysfs removal done by kobject_release()
when the object loses its last reference via kobject_put().

This is problematic because as long as it's not been removed from
sysfs, it is still present in the class kset and in sysfs directory
structure.

The presence in the class kset exposes a use after free bug fixed
by the previous patch, but the presence in sysfs means that until
the kobject is released, which can take a while (especially with
kobject debugging), any attempt at re-creating such as binding a
new device for that class/parent pair, will result in a sysfs
duplicate file name error.

This fixes it by instead doing an explicit kobject_del() when
the glue dir is empty, by keeping track of the number of
child devices of the gluedir.

This is made easy by the fact that all glue dir operations are
done with a global mutex, and there's already a function
(cleanup_glue_dir) called in all the right places taking that
mutex that can be enhanced for this. It appears that this was
in fact the intent of the function, but the implementation was
wrong.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Zubin Mithra <zsm@chromium.org>
Cc: Guenter Roeck <groeck@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-06 17:33:29 +01:00
..
power PM / core: Clear the direct_complete flag on errors 2018-10-13 09:18:54 +02:00
regmap regmap: Correct comparison in regmap_cached 2018-05-30 07:50:51 +02:00
attribute_container.c attribute_container: Fix typo 2016-08-31 15:13:56 +02:00
base.h PM / sleep: prohibit devices probing during suspend/hibernation 2015-11-30 14:47:22 +01:00
bus.c sysfs: Disable lockdep for driver bind/unbind files 2019-01-26 09:38:35 +01:00
cacheinfo.c drivers: base: cacheinfo: fix boot error message when acpi is enabled 2018-01-31 12:55:51 +01:00
class.c class_find_device: fix reference to argument "match" 2015-09-29 15:23:14 +02:00
component.c Merge 4.5-rc4 into driver-core-next 2016-02-14 14:29:55 -08:00
container.c
core.c drivers: core: Remove glue dirs from sysfs earlier 2019-02-06 17:33:29 +01:00
cpu.c x86/speculation/l1tf: Add sysfs reporting for l1tf 2018-08-15 18:14:45 +02:00
dd.c driver core: Partially revert "driver core: correct device's shutdown order" 2018-07-28 07:49:13 +02:00
devcoredump.c devcoredump: add scatterlist support 2016-04-15 11:20:32 -07:00
devres.c devm: make allocations numa aware by default 2015-10-09 17:00:33 -04:00
devtmpfs.c wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
dma-coherent.c drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() 2016-09-28 17:53:16 +02:00
dma-contiguous.c driver core update for 4.4-rc1 2015-11-04 21:50:37 -08:00
dma-mapping.c drivers/base dmam_declare_coherent_memory leaks 2016-08-31 15:19:55 +02:00
driver.c
firmware.c
firmware_class.c firmware: fix usermode helper fallback loading 2017-01-09 08:32:22 +01:00
hypervisor.c
init.c drivers: of/base: move of_init to driver_init 2015-05-26 19:55:56 -07:00
isa.c isa: Prevent NULL dereference in isa_bus driver callbacks 2017-12-14 09:28:11 +01:00
Kconfig sysfs/cpu: Add vulnerability folder 2018-01-17 09:38:57 +01:00
Makefile isa: Allow ISA-style drivers on modern systems 2016-06-17 20:21:12 -07:00
map.c
memory.c base/memory, hotplug: fix a kernel oops in show_valid_zones() 2017-02-09 08:08:28 +01:00
module.c base: make module_create_drivers_dir race-free 2016-06-15 19:21:31 -07:00
node.c treewide: replace obsolete _refok by __ref 2016-08-02 17:31:41 -04:00
pinctrl.c driver: base: pinctrl: return error from pinctrl_bind_pins() 2016-09-13 23:02:59 +02:00
platform-msi.c platform-msi: Free descriptors in platform_msi_domain_free() 2019-01-09 16:16:43 +01:00
platform.c driver core: platform: Don't read past the end of "driver_override" buffer 2017-10-12 11:51:24 +02:00
property.c device property: Track owner device of device property 2017-10-18 09:35:39 +02:00
soc.c base: soc: make it explicitly non-modular 2016-08-31 15:13:56 +02:00
syscore.c
topology.c topology/sysfs: provide drawer id and siblings attributes 2016-06-13 15:58:27 +02:00
transport_class.c