Re: [PATCH] secretmem: use SB_I_NOEXEC

From: Christian Brauner
Date: Tue Jul 08 2025 - 03:38:25 EST


On Mon, Jul 07, 2025 at 06:17:35PM +0100, Al Viro wrote:
> On Mon, Jul 07, 2025 at 02:10:36PM +0200, Christian Brauner wrote:
>
> > static int secretmem_init_fs_context(struct fs_context *fc)
> > {
> > - return init_pseudo(fc, SECRETMEM_MAGIC) ? 0 : -ENOMEM;
> > + struct pseudo_fs_context *ctx;
> > +
> > + ctx = init_pseudo(fc, SECRETMEM_MAGIC);
> > + if (!ctx)
> > + return -ENOMEM;
> > +
> > + fc->s_iflags |= SB_I_NOEXEC;
> > + fc->s_iflags |= SB_I_NODEV;
> > + return 0;
> > }
>
> What's the point of doing that *after* init_pseudo()? IOW, why not simply
>
> static int secretmem_init_fs_context(struct fs_context *fc)
> {
> fc->s_iflags |= SB_I_NOEXEC;
> fc->s_iflags |= SB_I_NODEV;
> return init_pseudo(fc, SECRETMEM_MAGIC) ? 0 : -ENOMEM;
> }
>
> seeing that init_pseudo() won't undo those?

Seemed cleaner to do it the other way around and get rid of the ? while
at it. I don't think it matters either way.