bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf 1/4] bpf: Check flow_dissector ctx accesses are aligned
@ 2025-08-01  9:47 Paul Chaignon
  2025-08-01  9:48 ` [PATCH bpf 2/4] bpf: Check netfilter " Paul Chaignon
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Paul Chaignon @ 2025-08-01  9:47 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Martin KaFai Lau, netfilter-devel,
	Pablo Neira Ayuso, Jozsef Kadlecsik, Petar Penkov,
	Florian Westphal

flow_dissector_is_valid_access doesn't check that the context access is
aligned. As a consequence, an unaligned access within one of the exposed
field is considered valid and later rejected by
flow_dissector_convert_ctx_access when we try to convert it.

The later rejection is problematic because it's reported as a verifier
bug with a kernel warning and doesn't point to the right instruction in
verifier logs.

Fixes: d58e468b1112 ("flow_dissector: implements flow dissector BPF hook")
Reported-by: syzbot+ccac90e482b2a81d74aa@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ccac90e482b2a81d74aa
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
---
 net/core/filter.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index c09a85c17496..da391e2b0788 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -9458,6 +9458,9 @@ static bool flow_dissector_is_valid_access(int off, int size,
 	if (off < 0 || off >= sizeof(struct __sk_buff))
 		return false;
 
+	if (off % size != 0)
+		return false;
+
 	if (type == BPF_WRITE)
 		return false;
 
-- 
2.43.0


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

end of thread, other threads:[~2025-08-02  0:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01  9:47 [PATCH bpf 1/4] bpf: Check flow_dissector ctx accesses are aligned Paul Chaignon
2025-08-01  9:48 ` [PATCH bpf 2/4] bpf: Check netfilter " Paul Chaignon
2025-08-01 15:54   ` Yonghong Song
2025-08-01 16:06   ` Eduard Zingerman
2025-08-01  9:49 ` [PATCH bpf 3/4] bpf: Improve ctx access verifier error message Paul Chaignon
2025-08-01 16:09   ` Eduard Zingerman
2025-08-01 16:19     ` Paul Chaignon
2025-08-01 16:24       ` Eduard Zingerman
2025-08-01 16:30   ` Yonghong Song
2025-08-01 21:47     ` Alexei Starovoitov
2025-08-02  0:00       ` Yonghong Song
2025-08-01  9:49 ` [PATCH bpf 4/4] selftests/bpf: Test for unaligned flow_dissector ctx access Paul Chaignon
2025-08-01 16:17   ` Eduard Zingerman
2025-08-01 16:33   ` Yonghong Song
2025-08-01 15:52 ` [PATCH bpf 1/4] bpf: Check flow_dissector ctx accesses are aligned Yonghong Song
2025-08-01 16:04 ` Eduard Zingerman
2025-08-01 16:30 ` patchwork-bot+netdevbpf

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).