mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Gellermann <christian.gellermann@codasip.com>
To: shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chris Gellermann <christian.gellermann@codasip.com>
Subject: [PATCH] selftests/unprivileged-remount: Strip ST_VALID before flag sanity check
Date: Fri, 31 Jul 2026 12:32:00 +0200	[thread overview]
Message-ID: <20260731103200.1015506-1-christian.gellermann@codasip.com> (raw)

Musl (and potentially other non-glibc C libraries) just copies the
statfs flags received from the kernel to the user [1]. This way,
ST_VALID may end up in the f_flags, a Linux-specific flag [2] that is
generally hidden from the user. The unprivileged-remout-test
fails when checking for unknown flags.

If we run on a non-glibc C library, strip ST_VALID before sanity
checking the flags.

Link: https://git.musl-libc.org/cgit/musl/tree/src/stat/statvfs.c#n40
Link: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_statvfs.h.html
Signed-off-by: Chris Gellermann <christian.gellermann@codasip.com>
---
 tools/testing/selftests/mount/unprivileged-remount-test.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/mount/unprivileged-remount-test.c b/tools/testing/selftests/mount/unprivileged-remount-test.c
index d2917054fe3a..c7bbed313495 100644
--- a/tools/testing/selftests/mount/unprivileged-remount-test.c
+++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
@@ -45,6 +45,10 @@
 # define MS_STRICTATIME (1 << 24)
 #endif
 
+#ifndef ST_VALID
+# define ST_VALID (0x0020)
+#endif
+
 static void die(char *fmt, ...)
 {
 	va_list ap;
@@ -123,6 +127,9 @@ static int read_mnt_flags(const char *path)
 		die("statvfs of %s failed: %s\n",
 			path, strerror(errno));
 	}
+#ifndef __GLIBC__
+	stat.f_flag &= ~ST_VALID;
+#endif
 	if (stat.f_flag & ~(ST_RDONLY | ST_NOSUID | ST_NODEV | \
 			ST_NOEXEC | ST_NOATIME | ST_NODIRATIME | ST_RELATIME | \
 			ST_SYNCHRONOUS | ST_MANDLOCK)) {
-- 
2.47.3


                 reply	other threads:[~2026-07-31 10:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260731103200.1015506-1-christian.gellermann@codasip.com \
    --to=christian.gellermann@codasip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /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

all inboxes | Powered by JetHome®