From: Luca Di Maio <luca.dimaio1@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: Luca Di Maio <luca.dimaio1@gmail.com>,
dimitri.ledkov@chainguard.dev, smoser@chainguard.dev,
"Darrick J. Wong" <djwong@kernel.org>
Subject: [PATCH v2] xfs_profile: fix permission octet when suid/guid is set
Date: Wed, 16 Apr 2025 18:14:13 +0200 [thread overview]
Message-ID: <20250416161422.964167-1-luca.dimaio1@gmail.com> (raw)
When encountering suid or sgid files, we already set the `u` or `g` property
in the prototype file.
Given that proto.c only supports three numbers for permissions, we need to
remove the redundant information from the permission, else it was incorrectly
parsed.
[v1] -> [v2]
Improve masking as suggested
Co-authored-by: Luca Di Maio <luca.dimaio1@gmail.com>
Co-authored-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
---
mkfs/xfs_protofile.in | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mkfs/xfs_protofile.in b/mkfs/xfs_protofile.in
index e83c39f..9418e7f 100644
--- a/mkfs/xfs_protofile.in
+++ b/mkfs/xfs_protofile.in
@@ -43,7 +43,9 @@ def stat_to_str(statbuf):
else:
sgid = '-'
- perms = stat.S_IMODE(statbuf.st_mode)
+ # We already register suid in the proto string, no need
+ # to also represent it into the octet
+ perms = stat.S_IMODE(statbuf.st_mode) & 0o777
return '%s%s%s%03o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \
statbuf.st_gid)
--
2.49.0
next reply other threads:[~2025-04-16 16:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 16:14 Luca Di Maio [this message]
2025-04-16 16:28 ` [PATCH v2] xfs_profile: fix permission octet when suid/guid is set Darrick J. Wong
2025-04-16 21:20 ` Luca Di Maio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250416161422.964167-1-luca.dimaio1@gmail.com \
--to=luca.dimaio1@gmail.com \
--cc=dimitri.ledkov@chainguard.dev \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=smoser@chainguard.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox