From: sashiko-bot@kernel.org
To: "Jan Koester" <jan.koester@tuxist.de>,
"Christian Brauner" <brauner@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: "Jan Kara" <jack@suse.cz>, "Theodore Y. Ts'o" <tytso@mit.edu>,
"Paul Moore" <paul@paul-moore.com>,
"Arnd Bergmann" <arnd@arndb.de>,
linux-security-module@vger.kernel.org,
linux-ext4@vger.kernel.org, audit@vger.kernel.org,
keyrings@vger.kernel.org, "Chuck Lever" <cel@kernel.org>,
"Jeff Layton" <jlayton@kernel.org>,
"Anna Schumaker" <anna@kernel.org>
Subject: Re: [RFC PATCH v2 36/41] selftests: add tests for UUID and GUID ids
Date: Thu, 22 Oct 2026 03:18:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-180937@kernel.org> (raw)
In-Reply-To: <fe7cdf53b4cc8e404778fb91dc5e44e48197b48a.1792552161.git.jan.koester@tuxist.de>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] selftests: uid_r: acl_v3() writes POSIX ACL xattr fields in host byte order
- [Medium] selftests/uid_r: fail instead of skip on ENOSYS in signalfd and ipc tests
- [Low] selftests: uid_r: FIXTURE_TEARDOWN() leaves mkdtemp() directories in /tmp
--
commit b236f646b555e600321fde8fdcedd3ac92eccb4e
Author: Jan Koester <jan.koester@tuxist.de>
selftests: add tests for UUID and GUID ids
This commit adds a kselftest suite for the *_r system calls and extended
kernel interfaces supporting UUID and GUID user and group identifiers. It
covers ID validation, credential switching, supplementary groups, filesystem
ownership on tmpfs, socket credentials, signalfd, SysV IPC, POSIX ACL v3
xattrs, /proc/self/status, and user namespace restrictions.
> diff --git a/tools/testing/selftests/uid_r/uid_r_test.c b/tools/testing/selftests/uid_r/uid_r_test.c
> new file mode 100644
> index 0000000000000..88397bf3dae7e
> --- /dev/null
> +++ b/tools/testing/selftests/uid_r/uid_r_test.c
> @@ -0,0 +1,535 @@
[ ... ]
> +/* a private tmpfs at a fresh directory, for file tests */
> +static void private_tmpfs(struct __test_metadata *_metadata, char *dir)
> +{
> + strcpy(dir, "/tmp/uid_r.XXXXXX");
> + ASSERT_EQ(0, unshare(CLONE_NEWNS));
> + ASSERT_EQ(0, mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL));
> + ASSERT_NE(NULL, mkdtemp(dir));
> + ASSERT_EQ(0, mount("tmpfs", dir, "tmpfs", 0, "mode=1777"));
> +}
[ ... ]
> +FIXTURE(uid_r) {
> + char dir[64];
> +};
> +
> +FIXTURE_SETUP(uid_r)
> +{
> + id_r id;
> +
> + if (geteuid() != 0)
> + SKIP(return, "needs root");
> + if (sys(__NR_getuid_r, (long)&id, 0, 0, 0, 0) == -ENOSYS)
> + SKIP(return, "no *_r system calls");
> + self->dir[0] = 0;
> +}
> +
> +FIXTURE_TEARDOWN(uid_r)
> +{
> +}
[Severity: Low]
Does FIXTURE_TEARDOWN(uid_r) leak the temporary /tmp/uid_r.XXXXXX mountpoint
directories created by private_tmpfs()?
In tools/testing/selftests/uid_r/uid_r_test.c, private_tmpfs() calls
unshare(CLONE_NEWNS) and makes mount propagation private, then calls
mkdtemp(dir) on the underlying /tmp filesystem before mounting tmpfs onto
dir.
When chown_r_statx, create_as_uuid_fsuid, posix_acl_v3, and user_namespace
call private_tmpfs(_metadata, self->dir), the private tmpfs mount is cleaned
up when the test child process exits, but because FIXTURE_TEARDOWN(uid_r) is
empty, the underlying self->dir directory in /tmp is never unmounted and
removed with rmdir(self->dir) when self->dir[0] is non-empty.
[ ... ]
> +TEST_F(uid_r, signalfd_uid_r)
> +{
> + id_r u = uuid(11), s0 = legacy(0), got;
> + struct signalfd_siginfo ssi;
> + sigset_t mask;
> + int sfd;
> +
> + sigemptyset(&mask);
> + sigaddset(&mask, SIGUSR1);
> + ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &mask, NULL));
> + sfd = signalfd(-1, &mask, 0);
> + ASSERT_LE(0, sfd);
[ ... ]
> +TEST_F(uid_r, ipc_stat_r)
> +{
> + id_r u = uuid(12), g = guid(13);
> + struct ipc_perm_r_t pr;
> + struct shmid_ds ds;
> + int id;
> +
> + memset(&pr, 0, sizeof(pr));
> + pr.mode = 0640;
> + pr.uid = u;
> + pr.gid = g;
> +
> + id = shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0600);
> + ASSERT_LE(0, id);
[Severity: Medium]
Should signalfd_uid_r and ipc_stat_r skip instead of failing when the kernel
is built without CONFIG_SIGNALFD or CONFIG_SYSVIPC?
In tools/testing/selftests/uid_r/uid_r_test.c, if CONFIG_SIGNALFD=n or
CONFIG_SYSVIPC=n, signalfd() in signalfd_uid_r and shmget() in ipc_stat_r
return -1 with errno set to ENOSYS, and ASSERT_LE() fails the tests outright
rather than calling SKIP().
Also, tools/testing/selftests/uid_r/config lists:
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_SYSVIPC=y
CONFIG_SIGNALFD=y
Should tools/testing/selftests/uid_r/config also include CONFIG_USER_NS=y so
that the user_namespace test is not skipped on kernels built using the
selftest config fragment?
[ ... ]
> +/* user::rw- user:<u>:r-- group::--- mask::r-- other::--- in version 3 */
> +static size_t acl_v3(unsigned char *buf, const id_r *u)
> +{
> + static const unsigned short ent[5][2] = {
> + { 0x01, 6 }, { 0x02, 4 }, { 0x04, 0 }, { 0x10, 4 }, { 0x20, 0 } };
> + unsigned char *e = buf + 4;
> + unsigned int ver = 3;
> +
> + memcpy(buf, &ver, 4);
> + for (int i = 0; i < 5; i++, e += 24) {
> + unsigned int type = 0;
> +
> + memset(e, 0, 24);
> + memcpy(e, &ent[i][0], 2);
> + memcpy(e + 2, &ent[i][1], 2);
> + if (ent[i][0] == 0x02) {
> + type = u->type;
> + memcpy(e + 8, u->uuid, 16);
> + }
> + memcpy(e + 4, &type, 4);
> + }
> + return 4 + 5 * 24;
> +}
> +
> +TEST_F(uid_r, posix_acl_v3)
> +{
> + unsigned char buf[256], got[256];
> + id_r u = uuid(20), s0 = legacy(0);
> + char path[96];
> + size_t len;
> + int fd;
> +
> + private_tmpfs(_metadata, self->dir);
> + snprintf(path, sizeof(path), "%s/acl", self->dir);
> + fd = open(path, O_CREAT | O_WRONLY, 0600);
> + ASSERT_LE(0, fd);
> + close(fd);
> + len = acl_v3(buf, &u);
> + if (setxattr(path, "system.posix_acl_access", buf, len, 0) &&
> + errno == EOPNOTSUPP)
> + SKIP(return, "tmpfs without POSIX ACLs");
> + ASSERT_EQ(len, getxattr(path, "system.posix_acl_access", got, sizeof(got)));
> + EXPECT_EQ(3, got[0]);
[Severity: Medium]
Won't acl_v3() and posix_acl_v3 fail or falsely skip on big-endian
architectures because the POSIX ACL xattr fields are serialized in host byte
order instead of little-endian?
In include/uapi/linux/posix_acl_xattr.h, struct posix_acl_xattr_header
defines a_version as __le32, and struct posix_acl_xattr_entry_r defines
e_tag and e_perm as __le16 and e_type as __le32. In fs/posix_acl.c,
posix_acl_fix_xattr_common() checks header->a_version against
cpu_to_le32(POSIX_ACL_XATTR_VERSION_R) and returns -EOPNOTSUPP on a
mismatch, while posix_acl_from_xattr_r() converts e_tag, e_perm, and e_type
using le16_to_cpu() and le32_to_cpu().
In tools/testing/selftests/uid_r/uid_r_test.c, acl_v3() copies host-endian
unsigned int ver, unsigned short ent[i][0] and ent[i][1], and unsigned int
type directly into buf with memcpy(). On big-endian systems, setxattr() in
posix_acl_v3 sees a byte-swapped a_version and fails with EOPNOTSUPP, which
posix_acl_v3 then treats as "tmpfs without POSIX ACLs" and skips even when
CONFIG_TMPFS_POSIX_ACL=y is enabled.
In addition, if setxattr() fails with an errno other than EOPNOTSUPP,
posix_acl_v3 does not assert that setxattr() succeeded before calling
getxattr().
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792552161.git.jan.koester@tuxist.de?part=36
next prev parent reply other threads:[~2026-10-22 3:18 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 3:15 [RFC PATCH v2 00/41] UUID and GUID user and group ids (*_r system calls) Jan Koester
2026-10-21 3:15 ` [RFC PATCH v2 01/41] uuid: move uuid_t and guid_t into <linux/uuid_types.h> Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 02/41] uapi: add <linux/uidgid_r.h> for 128 bit capable user and group ids Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 03/41] uidgid: add uid_is_legacy() and gid_is_legacy() Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 04/41] net: sock: read sk_uid through a seqcount Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 05/41] af_unix: keep sender ids in skb->cb only when they are classic ids Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 06/41] netlink: keep classic sender ids in skb->cb Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 07/41] Bluetooth: " Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 08/41] smb: client: use __kuid_val() for the unix SIDs of the caller Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 09/41] uidgid: let kuid_t and kgid_t hold a UUID or a GUID Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 10/41] uidgid: convert between kernel ids and the ids of the *_r system calls Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 11/41] fscrypt: show the whole uid in the description of user key claims Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 12/41] keys: name per-user keyrings of UUID and GUID users by the whole uid Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 13/41] ublk: refuse unprivileged devices to UUID and GUID users Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 14/41] nfsd: don't hand out uid 0 for read layouts of UUID-owned files Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 15/41] SUNRPC: name UUID and GUID users to gssd as uid_r= Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 16/41] ecryptfs: hash daemons by kuid_hash() Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 17/41] quota: don't account UUID and GUID owners Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 18/41] fs: keep UUID and GUID owners off filesystems that can't store them Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 19/41] cred: add the *_r variants of the get/set*id() system calls Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 20/41] groups: add getgroups_r() and setgroups_r() Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 21/41] fs: add chown_r(), lchown_r(), fchown_r() and fchownat_r() Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 22/41] arch: wire up the *_r uid and gid system calls Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 23/41] statx: report UUID and GUID owners Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 24/41] shmem, ramfs: allow " Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 25/41] uidgid: parse and print ids in their text form Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 26/41] proc: show UUID and GUID ids in status, accept them for loginuid Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 27/41] audit: log UUID and GUID ids in full Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 28/41] net: add SO_PEERCRED_R, SO_PEERGROUPS_R and SCM_CREDENTIALS_R Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 29/41] signal: report the sender's UUID or GUID uid in si_uid_r Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 30/41] ipc: add IPC_STAT_R and IPC_SET_R Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 31/41] ext4: add the uid_r feature for UUID and GUID owners Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 32/41] ext4: let uid_r be turned on while the filesystem is mounted Jan Koester
2026-10-22 3:17 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 33/41] posix_acl: support UUID and GUID entries Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 34/41] ext4: store ACLs with UUID and GUID entries on uid_r filesystems Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 35/41] Documentation: describe UUID and GUID user and group ids Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 36/41] selftests: add tests for UUID and GUID ids Jan Koester
2026-10-22 3:18 ` sashiko-bot [this message]
2026-10-21 3:15 ` [RFC PATCH v2 37/41] ovl: allow UUID and GUID owners when the upper layer does Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 38/41] devpts: allow UUID and GUID owners Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:15 ` [RFC PATCH v2 39/41] ksmbd: log in UUID and GUID users and map them to SIDs Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:16 ` [RFC PATCH v2 40/41] nfsd, nfs: carry UUID and GUID owners as their text form Jan Koester
2026-10-21 17:35 ` Chuck Lever
2026-10-22 2:52 ` Takeshi Nishimura
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:16 ` [RFC PATCH v2 41/41] Documentation: uid_r: describe SMB and NFSv4 Jan Koester
2026-10-22 3:18 ` sashiko-bot
2026-10-21 3:20 ` [RFC PATCH v2 00/41] UUID and GUID user and group ids (*_r system calls) jan Koester
2026-10-21 14:26 ` Adding dreaded Windows SID-style, or. Repeating history, the bad chapters. UUID/GUIDRe: " Lionel Cons
2026-10-22 17:00 ` Casey Schaufler
2026-10-22 18:26 ` Theodore Tso
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=sashiko-outbox-180937@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anna@kernel.org \
--cc=arnd@arndb.de \
--cc=audit@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=jack@suse.cz \
--cc=jan.koester@tuxist.de \
--cc=jlayton@kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=serge@hallyn.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/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