linux/drivers/misc
Linus Torvalds 7cd122b552 Some filesystems use a kinda-sorta controlled dentry refcount leak to pin
dentries of created objects in dcache (and undo it when removing those).
 Reference is grabbed and not released, but it's not actually _stored_
 anywhere.  That works, but it's hard to follow and verify; among other
 things, we have no way to tell _which_ of the increments is intended
 to be an unpaired one.  Worse, on removal we need to decide whether
 the reference had already been dropped, which can be non-trivial if
 that removal is on umount and we need to figure out if this dentry is
 pinned due to e.g. unlink() not done.  Usually that is handled by using
 kill_litter_super() as ->kill_sb(), but there are open-coded special
 cases of the same (consider e.g. /proc/self).
 
 Things get simpler if we introduce a new dentry flag (DCACHE_PERSISTENT)
 marking those "leaked" dentries.  Having it set claims responsibility
 for +1 in refcount.
 
 The end result this series is aiming for:
 
 * get these unbalanced dget() and dput() replaced with new primitives that
   would, in addition to adjusting refcount, set and clear persistency flag.
 * instead of having kill_litter_super() mess with removing the remaining
   "leaked" references (e.g. for all tmpfs files that hadn't been removed
   prior to umount), have the regular shrink_dcache_for_umount() strip
   DCACHE_PERSISTENT of all dentries, dropping the corresponding
   reference if it had been set.  After that kill_litter_super() becomes
   an equivalent of kill_anon_super().
 
 Doing that in a single step is not feasible - it would affect too many places
 in too many filesystems.  It has to be split into a series.
 
 This work has really started early in 2024; quite a few preliminary pieces
 have already gone into mainline.  This chunk is finally getting to the
 meat of that stuff - infrastructure and most of the conversions to it.
 
 Some pieces are still sitting in the local branches, but the bulk of
 that stuff is here.
 
 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQqUNBr3gm4hGXdBJlZ7Krx/gZQ6wUCaTEq1wAKCRBZ7Krx/gZQ
 643uAQC1rRslhw5l7OjxEpIYbGG4M+QaadN4Nf5Sr2SuTRaPJQD/W4oj/u4C2eCw
 Dd3q071tqyvm/PXNgN2EEnIaxlFUlwc=
 =rKq+
 -----END PGP SIGNATURE-----

Merge tag 'pull-persistency' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull persistent dentry infrastructure and conversion from Al Viro:
 "Some filesystems use a kinda-sorta controlled dentry refcount leak to
  pin dentries of created objects in dcache (and undo it when removing
  those). A reference is grabbed and not released, but it's not actually
  _stored_ anywhere.

  That works, but it's hard to follow and verify; among other things, we
  have no way to tell _which_ of the increments is intended to be an
  unpaired one. Worse, on removal we need to decide whether the
  reference had already been dropped, which can be non-trivial if that
  removal is on umount and we need to figure out if this dentry is
  pinned due to e.g. unlink() not done. Usually that is handled by using
  kill_litter_super() as ->kill_sb(), but there are open-coded special
  cases of the same (consider e.g. /proc/self).

  Things get simpler if we introduce a new dentry flag
  (DCACHE_PERSISTENT) marking those "leaked" dentries. Having it set
  claims responsibility for +1 in refcount.

  The end result this series is aiming for:

   - get these unbalanced dget() and dput() replaced with new primitives
     that would, in addition to adjusting refcount, set and clear
     persistency flag.

   - instead of having kill_litter_super() mess with removing the
     remaining "leaked" references (e.g. for all tmpfs files that hadn't
     been removed prior to umount), have the regular
     shrink_dcache_for_umount() strip DCACHE_PERSISTENT of all dentries,
     dropping the corresponding reference if it had been set. After that
     kill_litter_super() becomes an equivalent of kill_anon_super().

  Doing that in a single step is not feasible - it would affect too many
  places in too many filesystems. It has to be split into a series.

  This work has really started early in 2024; quite a few preliminary
  pieces have already gone into mainline. This chunk is finally getting
  to the meat of that stuff - infrastructure and most of the conversions
  to it.

  Some pieces are still sitting in the local branches, but the bulk of
  that stuff is here"

* tag 'pull-persistency' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (54 commits)
  d_make_discardable(): warn if given a non-persistent dentry
  kill securityfs_recursive_remove()
  convert securityfs
  get rid of kill_litter_super()
  convert rust_binderfs
  convert nfsctl
  convert rpc_pipefs
  convert hypfs
  hypfs: swich hypfs_create_u64() to returning int
  hypfs: switch hypfs_create_str() to returning int
  hypfs: don't pin dentries twice
  convert gadgetfs
  gadgetfs: switch to simple_remove_by_name()
  convert functionfs
  functionfs: switch to simple_remove_by_name()
  functionfs: fix the open/removal races
  functionfs: need to cancel ->reset_work in ->kill_sb()
  functionfs: don't bother with ffs->ref in ffs_data_{opened,closed}()
  functionfs: don't abuse ffs_data_closed() on fs shutdown
  convert selinuxfs
  ...
2025-12-05 14:36:21 -08:00
..
altera-stapl
amd-sbi misc: amd-sbi: Clarify that this is a BMC driver 2025-10-22 08:02:57 +02:00
bcm-vk treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
c2port sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
cardreader Char/Misc/IIO/Binder changes for 6.18-rc1 2025-10-04 16:26:32 -07:00
cb710
eeprom eeprom: at25: make FRAM device ID error message more precise 2025-09-06 15:58:23 +02:00
genwqe misc: genwqe: Fix incorrect cmd field being reported in error 2025-09-06 16:00:32 +02:00
ibmasm ibmasmfs: get rid of ibmasmfs_dir_ops 2025-11-16 01:35:04 -05:00
keba misc: keba: Fix kernfs warning on module unload 2025-01-10 10:16:39 +01:00
lis3lv02d misc: Fix spelling mistake "STMicroeletronics" -> "STMicroelectronics" 2025-08-19 12:37:04 +02:00
lkdtm - Remove a bunch of asm implementing condition flags testing in KVM's 2025-10-11 11:19:16 -07:00
mchp_pci1xxxx treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
mei mei: fix error flow in probe 2025-11-03 10:02:04 +09:00
ocxl powerpc, ocxl: Fix extraction of struct xive_irq_data 2025-10-13 09:40:55 +05:30
pvpanic
rp1 misc: rp1: RaspberryPi RP1 misc driver 2025-06-16 11:50:34 -07:00
sgi-gru
sgi-xp treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
uacce uacce: Remove unnecessary IOMMU_DEV_FEAT_IOPF 2025-04-28 13:04:34 +02:00
vmw_vmci vmci: Prevent the dispatching of uninitialized payloads 2025-07-16 14:23:57 +02:00
Kconfig misc: rp1: RaspberryPi RP1 misc driver 2025-06-16 11:50:34 -07:00
Makefile char: misc: Move drivers/misc/misc_minor_kunit.c to drivers/char/ 2025-08-19 12:41:17 +02:00
ad525x_dpot-i2c.c
ad525x_dpot-spi.c
ad525x_dpot.c misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg() 2025-09-06 15:59:46 +02:00
ad525x_dpot.h
apds990x.c misc: apds990x: Drop superfluous return statement 2025-08-19 12:37:13 +02:00
apds9802als.c
atmel-ssc.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
bh1770glc.c
cs5535-mfgpt.c x86/msr: Add explicit includes of <asm/msr.h> 2025-05-02 10:23:47 +02:00
ds1682.c sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
dummy-irq.c
dw-xdata-pcie.c dw-xdata: Use str_write_read() in dw_xdata_start() and dw_xdata_perf() 2025-09-06 15:59:39 +02:00
enclosure.c misc: enclosure: Use str_on_off() helper 2025-06-24 16:46:04 +01:00
fastrpc.c misc: fastrpc: Fix dma_buf object leak in fastrpc_map_lookup 2025-10-22 08:03:24 +02:00
gehc-achc.c
hi6421v600-irq.c misc: Use dev_fwnode() 2025-06-24 16:45:08 +01:00
hisi_hikey_usb.c misc: hisi_hikey_usb: Use str_enabled_disabled() in hub_power_ctrl() 2025-08-19 12:37:15 +02:00
hmc6352.c
hpilo.c
hpilo.h
ibmvmc.c
ibmvmc.h
ics932s401.c
isl29003.c
isl29020.c misc: isl29020: Fix the wrong format specifier 2024-11-12 12:54:53 +01:00
kgdbts.c
lan966x_pci.c misc: Add support for LAN966x PCI device 2024-10-24 12:09:33 +02:00
lan966x_pci.dtso misc: lan966x_pci: Fix dtc warn 'Missing interrupt-parent' 2024-11-04 14:34:25 +01:00
lattice-ecp3-config.c
mrvl_cn10k_dpi.c
nsm.c
ntsync.c ntsync: convert ntsync_obj_get_fd() to FD_PREPARE() 2025-11-28 12:42:36 +01:00
open-dice.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
pch_phub.c sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
pci_endpoint_test.c misc: pci_endpoint_test: Cleanup extra 0 initialization 2025-08-27 18:39:32 +05:30
phantom.c
qcom-coincell.c
rpmb-core.c
smpro-errmon.c
smpro-misc.c
sram-exec.c
sram.c Driver core changes for 6.17-rc1 2025-07-29 12:15:39 -07:00
sram.h
ti_fpc202.c treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
tifm_7xx1.c
tifm_core.c
tps6594-esm.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
tps6594-pfsm.c misc: tps6594-pfsm: Add TI TPS652G1 PMIC PFSM 2025-07-10 09:58:06 +01:00
tsl2550.c
vcpu_stall_detector.c misc: vcpu_stall_detector: Switch to use hrtimer_setup() 2025-02-18 11:19:04 +01:00
vmw_balloon.c vmw_balloon: indicate success when effectively deflating during migration 2025-10-21 15:46:17 -07:00
xilinx_sdfec.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
xilinx_tmr_inject.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
xilinx_tmr_manager.c