All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Christian Brauner <brauner@kernel.org>
Cc: Amir Goldstein <amir73il@gmail.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Giuseppe Scrivano <giuseppe@scrivano.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	bpf@vger.kernel.org, linux-unionfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH vfs v1] selftests/bpf: Match overlayfs open error in uprobe_multi_test
Date: Fri, 20 Nov 2026 17:46:38 -0700	[thread overview]
Message-ID: <20261121004638.2973704-1-ihor.solodrai@linux.dev> (raw)

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


                 reply	other threads:[~2026-11-21  0:46 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=20261121004638.2973704-1-ihor.solodrai@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=amir73il@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=giuseppe@scrivano.org \
    --cc=jolsa@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.