Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: fix crash in bpf_path_d_path() for exiting tasks
@ 2026-10-20 10:50 Matt Bobrowski
  2026-10-20 10:50 ` [PATCH bpf-next 1/2] " Matt Bobrowski
  2026-10-20 10:50 ` [PATCH bpf-next 2/2] selftests/bpf: test bpf_path_d_path() on a file released at task exit Matt Bobrowski
  0 siblings, 2 replies; 7+ messages in thread
From: Matt Bobrowski @ 2026-10-20 10:50 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai, Christian Brauner, Alexander Viro, Jan Kara,
	linux-fsdevel, Matt Bobrowski

bpf_path_d_path() can run on a file released from exit_task_work(),
after exit_fs() has cleared the task's fs, as a BPF LSM program attached
to file_release does whenever a task exits holding the last reference to
an open file. d_path() then dereferences the NULL fs.

Patch 1 returns -EINVAL from bpf_path_d_path() when current->fs is NULL.
Patch 2 adds a selftest that crashes the kernel without it.

Matt Bobrowski (2):
  bpf: fix crash in bpf_path_d_path() for exiting tasks
  selftests/bpf: test bpf_path_d_path() on a file released at task exit

 fs/bpf_fs_kfuncs.c                            |  8 +++
 .../selftests/bpf/prog_tests/fs_kfuncs.c      | 51 +++++++++++++++++++
 .../selftests/bpf/progs/test_path_d_path.c    | 35 +++++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/test_path_d_path.c


base-commit: 0007654a7bf13ef2a19afd398bbc6507087f19fd
-- 
2.47.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-20 19:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 10:50 [PATCH bpf-next 0/2] bpf: fix crash in bpf_path_d_path() for exiting tasks Matt Bobrowski
2026-10-20 10:50 ` [PATCH bpf-next 1/2] " Matt Bobrowski
2026-10-20 17:36   ` Song Liu
2026-10-20 18:24   ` Alexei Starovoitov
2026-10-20 19:02     ` Al Viro
2026-10-20 10:50 ` [PATCH bpf-next 2/2] selftests/bpf: test bpf_path_d_path() on a file released at task exit Matt Bobrowski
2026-10-20 17:37   ` Song Liu

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