Re: [syzbot] [bpf?] [net?] general protection fault in dev_map_enqueue

From: Edward Adam Davis
Date: Sat Mar 30 2024 - 01:53:23 EST


please test null ptr deref in dev_map_enqueue

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git 443574b03387

diff --git a/net/core/filter.c b/net/core/filter.c
index 8adf95765cdd..721b85aebf58 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4381,6 +4381,10 @@ static __always_inline int __xdp_do_redirect_frame(struct bpf_redirect_info *ri,
err = dev_map_enqueue_multi(xdpf, dev, map,
ri->flags & BPF_F_EXCLUDE_INGRESS);
} else {
+ if (unlikely(!fwd)) {
+ err = -EINVAL;
+ break;
+ }
err = dev_map_enqueue(fwd, xdpf, dev);
}
break;