Re: [PATCH RFC 35/38] proc: sysctl: don't hold the tables while readdir copies to userspace
From: Jan Kara
Date: Mon Nov 09 2026 - 07:39:44 EST
On Fri 06-11-26 15:08:12, Christian Brauner wrote:
> On Thu, 5 Nov 2026 13:55:56 +0100, Jan Kara wrote:
> > So I didn't really carefully check all the details but overall this looks
> > sane to me. Just one thing that was confusing me is: Why is sysctl_dirent
> > separate from sysctl_cursor? Wouldn't it be more logical for sysctl_cursor
> > itself to start what it needs to pin the entry it wants to restart from?
>
> Because they have different lifetimes. The cursor lives in the file
> between two getdents() calls. So nothing in the cursor may be something
> that unregistering the sysctl table waits for. So it only remembers the
> name of the last entry and the position behind it.
>
> sysctl_dirent is the state of one call. It does hold a grabbed header
> which we drop before the call returns.
>
> If the cursor were to hold the header too then every open directory
> would keep the table of its last entry pinned until the next getdents()
> or close() which is the indefinite delay this patch kills.
Right. Thanks for explanation!
Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR