Linux Overlay Filesystem development
 help / color / mirror / Atom feed
* [PATCH vfs v1] selftests/bpf: Match overlayfs open error in uprobe_multi_test
@ 2026-11-21  0:46 Ihor Solodrai
  0 siblings, 0 replies; only message in thread
From: Ihor Solodrai @ 2026-11-21  0:46 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Amir Goldstein, Miklos Szeredi, Giuseppe Scrivano,
	Alexei Starovoitov, Andrii Nakryiko, Eduard Zingerman, Jiri Olsa,
	bpf, linux-unionfs, linux-fsdevel

The attach_api_fails_ovl_no_data subtest expects BPF_LINK_CREATE to
return -ENOENT. Overlayfs commit 0d5e729c515f ("ovl: return EIO if the
lowerdata is missing") maps the lookup error to -EIO when a metacopy
file exists but its backing data is missing. This fails the assertion
in aarch64 linux-next CI with "actual -5 != expected -2".

Check that the overlay entry exists with O_PATH, then attach the
uprobe before opening the file for reading so the attach still
exercises lazy lookup. Compare the attach error with the error
reported by open() on the same file.

Fixes: d21b93ab6068 ("selftests/bpf: add uprobe_multi test on overlayfs without data")
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>

---

Caught by BPF CI on linux-next:
https://github.com/kernel-patches/bpf/actions/runs/44811929601/job/136556160720

---
 .../bpf/prog_tests/uprobe_multi_test.c        | 29 ++++++++++++++-----
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
index 907d8c6d5ec9..e0ebe578943b 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
@@ -588,6 +588,7 @@ enum ovl_no_data_stage {
 struct ovl_no_data_result {
 	enum ovl_no_data_stage stage;
 	int err;
+	int open_err;
 };
 
 /*
@@ -628,20 +629,33 @@ static void ovl_no_data_child(int prog_fd, const char *dir, int wfd)
 		     strlen("/missing"), 0))
 		goto out_errno;
 
-	res.stage = OVL_NO_DATA_MOUNT;
 	snprintf(data, sizeof(data), "lowerdir=%s/lower::%s/data", dir, dir);
 	snprintf(path, sizeof(path), "%s/merged", dir);
-	if (mount("overlay", path, "overlay", 0, data))
+	if (mount("overlay", path, "overlay", 0, data)) {
+		res.stage = OVL_NO_DATA_MOUNT;
 		goto out_errno;
+	}
 
-	res.stage = OVL_NO_DATA_ATTACH;
 	snprintf(path, sizeof(path), "%s/merged/f", dir);
+	/* Check that the overlay entry exists without resolving its lowerdata. */
+	fd = open(path, O_PATH);
+	if (fd < 0)
+		goto out_errno;
+	close(fd);
+
+	res.stage = OVL_NO_DATA_ATTACH;
 	opts.uprobe_multi.path = path;
 	opts.uprobe_multi.offsets = &offset;
 	opts.uprobe_multi.cnt = 1;
 	res.err = bpf_link_create(prog_fd, 0, BPF_TRACE_UPROBE_MULTI, &opts);
 	if (res.err >= 0)
 		close(res.err);
+
+	fd = open(path, O_RDONLY);
+	if (fd < 0)
+		res.open_err = -errno;
+	else
+		close(fd);
 	goto out;
 
 out_errno:
@@ -653,9 +667,8 @@ static void ovl_no_data_child(int prog_fd, const char *dir, int wfd)
 }
 
 /*
- * The data of a metacopy file in an overlayfs data-only layer is looked up
- * lazily. If it can't be found attaching must fail with the error from the
- * lookup.
+ * Opening a metacopy file and attaching a uprobe both resolve its lowerdata
+ * lazily. Attaching must report the same lookup error as open().
  */
 static void test_attach_api_fails_ovl_no_data(void)
 {
@@ -701,7 +714,9 @@ static void test_attach_api_fails_ovl_no_data(void)
 	}
 	if (!ASSERT_EQ(res.stage, OVL_NO_DATA_ATTACH, "setup"))
 		goto cleanup_pipe;
-	ASSERT_EQ(res.err, -ENOENT, "link_create");
+	if (!ASSERT_TRUE(res.open_err == -ENOENT || res.open_err == -EIO, "open_errno"))
+		goto cleanup_pipe;
+	ASSERT_EQ(res.err, res.open_err, "link_create");
 
 cleanup_pipe:
 	if (pipefd[0] >= 0)

base-commit: d21b93ab6068a832855d5d9d31c4b02c91245227
-- 
2.56.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-21  0:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21  0:46 [PATCH vfs v1] selftests/bpf: Match overlayfs open error in uprobe_multi_test Ihor Solodrai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox