Re: [PATCH v2 20/21] fuse: use passthrough getattr in setattr suid/sgid handling

Joanne Koong <[email protected]> Mon, 18 May 2026 17:01:41 -0700
Newsgroups org.kernel.vger.linux-unionfs,dev.linux.lists.fuse-devel
Message-ID <CAJnrk1Y+YO79e=yvzKaBT9XcCV_ht899nQjzhQnKzJMjt4UVFw@mail.gmail.com>
On Sat, May 16, 2026 at 3:23 PM Amir Goldstein <[email protected]> wrote:
>
> On Sat, May 16, 2026 at 3:20 AM Joanne Koong <[email protected]> wrote:
> >
> > On Fri, May 15, 2026 at 5:53 PM Joanne Koong <[email protected]> wrote:
> > >
> > > When refreshing i_mode for suid/sgid kill during setattr, use
> > > passthrough getattr if the inode has that enabled.
> > >
> > > Signed-off-by: Joanne Koong <[email protected]>
> > > ---
> > >  fs/fuse/dir.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> > > index b67b3b334e69..fd1b3fd86968 100644
> > > --- a/fs/fuse/dir.c
> > > +++ b/fs/fuse/dir.c
> > > @@ -2524,7 +2524,11 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
> > >                          * ia_mode calculation may have used stale i_mode.
> > >                          * Refresh and recalculate.
> > >                          */
> > > -                       ret = fuse_do_getattr(idmap, inode, NULL, file);
> > > +                       if (fuse_passthrough_op(inode, FUSE_GETATTR))
> > > +                               ret = fuse_passthrough_getattr(inode, NULL,
> > > +                                                              STATX_MODE, 0);
> > > +                       else
> > > +                               ret = fuse_do_getattr(idmap, inode, NULL, file);
> >
> > I left this part untouched from v1 but there was a discussion [1]
> > about whether to enforce that setattr must be passed through if
> > getattr is passed through [1]. I think there might be some use cases
> > though where having only getattr passed through and not setattr is
> > useful (eg server wants fast stat() but needs to intercept attribute
> > changes for access control or policy enforcement).
>
> Of course there is. I think I was misunderstood.
>
> What I meant was that *specifically* for the getattr for this purpose
> of killpriv, it may make sense to ask the server's mode for
> calculating the setattr mode for the server.

Ah gotcha, I misinterpreted your comment from v1. Thanks for clarifying.

Thanks again for reviewing this series.

>
> But this is just a hunch.
> I could be wrong and I have no strong feelings either way.
>
> > I'm not sure if you
> > still feel it's better to keep it simple with enforcing that
> > getattr+setattr rmust always be passed through together, Amir, but if
> > so I'm happy to add that in.
>
> No need.
>
> Thanks,
> Amir.