Re: [PATCH v2] proc: only bump parent nlink when registering directories
From: Christian Brauner
Date: Wed Jun 17 2026 - 09:24:19 EST
On Sat, 13 Jun 2026 21:10:05 +0000, Krzysztof Wilczyński wrote:
> proc_register() increments the parent directory's link count for every
> entry it registers, while remove_proc_entry() and remove_proc_subtree()
> decrement it only when the removed entry is a directory. Regular files
> thus inflate the parent's count while they exist, and leak one link
> permanently on every create and remove cycle.
>
> For example, /proc/bus/pci/00 with twenty-two device files and no
> subdirectories reports nlink 24 instead of 2, and SR-IOV VF enable
> and disable cycles, each creating and removing the VF config space
> entries under /proc/bus/pci/<bus>, inflate the link count of that
> directory without bound.
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] proc: only bump parent nlink when registering directories
https://git.kernel.org/vfs/vfs/c/552864f6ac8f