selftests/unprivileged-remount: Strip ST_VALID before flag sanity check
PATCH 1/1 selftests/unprivileged-remount: Strip ST_VALID before flag sanity check
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.
Signed-off-by Chris Gellermann <[email protected]>
--- tools/testing/selftests/mount/unprivileged-remount-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/testing/selftests/mount/unprivileged-remount-test.c +7 -0
@@ -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 )) {
Signature · 1 line
2.47.3