Re: [PATCH] xfs_profile: fix permission octet when suid/guid is set

Luca Di Maio
2025-04-16T16:17:12Z

On Wed, Apr 16, 2025 at 5:40 PM Darrick J. Wong <djwong@kernel.org> wrote:
> Hmm. The mode parser only pays attention to positions 3-5 in the mode
> string:
>
> val = 0;
> for (i = 3; i < 6; i++) {
> if (mstr[i] < '0' || mstr[i] > '7') {
> fprintf(stderr, _("%s: bad format string %s\n"),
> progname, mstr);
> exit(1);
> }
> val = val * 8 + mstr[i] - '0';
> }
> mode |= val;
>
> so I think xfs_protofile should be masking more:
>
> perms = stat.S_IMODE(statbuf.st_mode) & 0o777
>
> because otherwise we leak the sticky bit (S_ISVTX) into the protofile.
>
> --D
>
> > return '%s%s%s%03o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \
> > statbuf.st_gid)
> > 2.49.0
> >

Thanks Darrik,
I've sent a v2 Patch implementing this, co-authoring you
let me know if this is ok

Thanks
L.