Re: [PATCH RFC v2 02/23] fs: add scoped_with_init_fs()
From: Jann Horn
Date: Mon Mar 09 2026 - 11:27:43 EST
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(¤t->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().