From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: "Shuah Khan" <shuah@kernel.org>,
"Mickaël Salaün" <mic@digikod.net>,
"Günther Noack" <gnoack@google.com>
Cc: linux-kernel@vger.kernel.org,
Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
linux-kselftest@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: [PATCH] selftests: binderfs: skip the stress test without binderfs
Date: Fri, 25 Sep 2026 16:34:07 +0300 [thread overview]
Message-ID: <20260925133435.3635453-1-eva.kurchatova@virtuozzo.com> (raw)
binderfs_stress mounts binderfs and asserts on the first mount, so on
a kernel without CONFIG_ANDROID_BINDERFS the case fails rather than
reporting that the filesystem is not there.
Ask /proc/filesystems whether the kernel has it, the way
supports_filesystem() in the landlock tests and check_resctrlfs_support()
in the resctrl ones already do, and skip when it does not.
Probing with a mount instead would not work here: the test is meant to
run unprivileged, and path_mount() rejects an unprivileged caller in
may_mount() before do_new_mount() ever looks the filesystem type up, so
the probe would see EPERM whether binderfs is there or not. The child
would then still reach the real mount inside its userns and fail.
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
.../filesystems/binderfs/binderfs_test.c | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
index a1a79a6fef17..70f0391136c4 100644
--- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
+++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
@@ -36,6 +36,28 @@
fd = -EBADF; \
}
+static bool binderfs_supported(void)
+{
+ char line[128];
+ bool ret = false;
+ FILE *f;
+
+ f = fopen("/proc/filesystems", "r");
+ if (!f)
+ return true; /* Cannot tell, let the test run and report. */
+
+ while (fgets(line, sizeof(line), f)) {
+ /* binderfs has no backing device, hence the "nodev" prefix. */
+ if (!strcmp(line, "nodev\tbinder\n")) {
+ ret = true;
+ break;
+ }
+ }
+
+ fclose(f);
+ return ret;
+}
+
static void change_mountns(struct __test_metadata *_metadata)
{
int ret;
@@ -388,6 +410,9 @@ TEST(binderfs_stress)
char binderfs_mntpt[] = P_tmpdir "/binderfs_XXXXXX",
device_path[sizeof(P_tmpdir "/binderfs_XXXXXX/") + BINDERFS_MAX_NAME];
+ if (!binderfs_supported())
+ SKIP(return, "The Android binderfs filesystem is not available");
+
ret = socketpair(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0, syncfds);
ASSERT_EQ(ret, 0) {
TH_LOG("%s - Failed to create socket pair", strerror(errno));
--
2.55.0
next reply other threads:[~2026-09-25 13:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 13:34 Eva Kurchatova [this message]
2026-09-25 13:40 ` [PATCH] selftests: binderfs: skip the stress test without binderfs sashiko-bot
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=20260925133435.3635453-1-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=gnoack@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--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