Re: [PATCH v2] proc: only bump parent nlink when registering directories

From: Krzysztof Wilczyński

Date: Mon Jul 06 2026 - 15:16:14 EST


Hello,

> > > > 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.
> > [...]
> > > [1/1] proc: only bump parent nlink when registering directories
> > > https://git.kernel.org/vfs/vfs/c/552864f6ac8f
> >
> > I assume this got lost? Seems its missing from 7.2-rc1, sadly.
>
> I don't think it got lost. I'd expect Christian to send the fix for 7.2-rc2
> (he merged it to his tree only during a merge window). I've checked his
> tree to verify but apparently Christian didn't push out vfs.fixes or
> vfs.all branch for a couple of weeks.

I saw the patch landed. Thank you for help!

All the best,

Krzysztof