Re: [PATCH vfs v2] bpf: Allow bpf_d_path() from filp_close_sync()

From: Ihor Solodrai

Date: Wed Oct 21 2026 - 13:28:34 EST


On 2026-10-21 1:54 a.m., Christian Brauner wrote:
On Fri, Sep 25, 2026 at 02:03:47PM -0700, Ihor Solodrai wrote:
The d_path selftest closes its descriptors with close_range() so that
its fentry program on filp_close() runs. The vfs commit
c1ed65ea167b ("fs: make close_range() synchronous") switched
close_range() to filp_close_sync(), so the program still attaches but
is never called:

test_d_path_basic:FAIL:close trampoline for filp_close was not called

With that series, close(), close_range() and the closes on exec and
exit all go through filp_close_sync(). Few paths still reach
filp_close(), dup2() being one of them, so a program on filp_close()
no longer sees most file closes.

Allow bpf_d_path() from filp_close_sync(), but only from fentry.
filp_close_sync() drops the last file reference inline, so by the time
an fexit program runs, file->f_path may already be freed, with no RCU
delay for NORCU dentries such as pipes and sockets.

Attach the selftest program to filp_close_sync() and keep triggering
it with close_range().

Add a test rejecting bpf_d_path() from fexit/filp_close_sync.

Assisted-by: LLM
Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx>

---

This seems fine to me. Sashiko has some comments though.
Maybe go through them and resend as necessary.

I looked at them when sashiko replied and dismissed.
Should've commented.

I'll respin anyways to rebase, it's been a month.

Thanks for taking a look.