Re: [PATCH RFC v2 02/23] fs: add scoped_with_init_fs()

From: Christian Brauner

Date: Tue Mar 10 2026 - 07:45:55 EST


On Mon, Mar 09, 2026 at 04:19:36PM +0100, Jann Horn wrote:
> On Fri, Mar 6, 2026 at 12:30 AM Christian Brauner <brauner@xxxxxxxxxx> wrote:
> > Similar to scoped_with_kernel_creds() allow a temporary override of
> > current->fs to serve the few places where lookup is performed from
> > kthread context or needs init's filesytem state.
> >
> > Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
> [...]
> > +static inline struct fs_struct *__override_init_fs(void)
> > +{
> > + struct fs_struct *fs;
> > +
> > + fs = current->fs;
> > + smp_store_release(&current->fs, current->fs);
> > + return fs;
> > +}
>
> See my comments on patch 15 - I think you'll have to reorder this
> patch after the introduction of task_struct::real_fs and changing
> procfs to access task_struct::real_fs.
>
> I'm not sure what the smp_store_release() is supposed to pair with; if
> you get rid of remote access to task_struct::fs as I suggest on patch
> 15, it could be a plain store, otherwise it would have to happen under
> task_lock().

Yes, that's right. I'll remove that.