linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/2] bpf, xdp: clean adjust_{head,meta} memory when offset < 0
@ 2025-03-31  3:23 Jiayuan Chen
  2025-03-31  3:23 ` [PATCH bpf v2 1/2] bpf, xdp: clean head/meta when expanding it Jiayuan Chen
  2025-03-31  3:23 ` [PATCH bpf v2 2/2] selftests/bpf: add perf test for adjust_{head,meta} Jiayuan Chen
  0 siblings, 2 replies; 11+ messages in thread
From: Jiayuan Chen @ 2025-03-31  3:23 UTC (permalink / raw)
  To: bpf
  Cc: mrpre, Jiayuan Chen, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jesper Dangaard Brouer, Mykola Lysenko,
	Shuah Khan, Willem de Bruijn, Jason Xing, Anton Protopopov,
	Abhishek Chauhan, Jordan Rome, Martin Kelly, David Lechner,
	linux-kernel, netdev, linux-kselftest

This patchset originates from my attempt to resolve a KMSAN warning that
has existed for over 3 years:
https://syzkaller.appspot.com/bug?extid=0e6ddb1ef80986bdfe64

Previously, we had a brief discussion in this thread about whether we can
simply perform memset in adjust_{head,meta}:
https://lore.kernel.org/netdev/20250328043941.085de23b@kernel.org/T/#t

Unfortunately, I couldn't find a similar topic in the mail list, but I did
find a similar security-related commit:
commit 6dfb970d3dbd ("xdp: avoid leaking info stored in frame data on page reuse")

I just create a new topic here and make subject more clear, we can discuss
this here.

Meanwhile, I also discovered a related issue that led to a CVE,specifically
the Facebook Katran vulnerability (https://vuldb.com/?id.246309).

Currently, even with unprivileged functionality disabled, a user can load
a BPF program using CAP_BPF and CAP_NET_ADMIN, which I believe we should
avoid exposing kernel memory directly to users now.

Regarding performance considerations, I added corresponding results to the
selftest, testing common MAC headers and IP headers of various sizes.

Compared to not using memset, the execution time increased by 2ns, but I
think this is negligible considering the entire net stack.

Jiayuan Chen (2):
  bpf, xdp: clean head/meta when expanding it
  selftests/bpf: add perf test for adjust_{head,meta}

 include/uapi/linux/bpf.h                      |  8 +--
 net/core/filter.c                             |  5 +-
 tools/include/uapi/linux/bpf.h                |  6 ++-
 .../selftests/bpf/prog_tests/xdp_perf.c       | 52 ++++++++++++++++---
 tools/testing/selftests/bpf/progs/xdp_dummy.c | 14 +++++
 5 files changed, 72 insertions(+), 13 deletions(-)

-- 
2.47.1


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

end of thread, other threads:[~2025-04-04  0:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31  3:23 [PATCH bpf v2 0/2] bpf, xdp: clean adjust_{head,meta} memory when offset < 0 Jiayuan Chen
2025-03-31  3:23 ` [PATCH bpf v2 1/2] bpf, xdp: clean head/meta when expanding it Jiayuan Chen
2025-04-03  8:17   ` Jesper Dangaard Brouer
2025-04-03 14:24   ` Alexei Starovoitov
2025-04-03 14:32     ` Willem de Bruijn
2025-04-04  0:28       ` Alexei Starovoitov
2025-04-04  0:27     ` Jiayuan Chen
2025-04-04  0:29       ` Alexei Starovoitov
2025-03-31  3:23 ` [PATCH bpf v2 2/2] selftests/bpf: add perf test for adjust_{head,meta} Jiayuan Chen
2025-04-03  0:24   ` Jakub Kicinski
2025-04-03  9:37     ` Jesper Dangaard Brouer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).