In the Linux kernel, the following vulnerability has been resolved:
net: clear the dst when changing skb protocol
A not-so-careful NAT46 BPF program can crash the kernel if it indiscriminately flips ingress packets from v4 to v6:
BUG: kernel NULL pointer dereference, address: 0000000000000000 ip6rcvcore (net/ipv6/ip6input.c:190:20) ipv6rcv (net/ipv6/ip6input.c:306:8) processbacklog (net/core/dev.c:6186:4) napipoll (net/core/dev.c:6906:9) netrxaction (net/core/dev.c:7028:13) dosoftirq (kernel/softirq.c:462:3) netifrx (net/core/dev.c:5326:3) devloopbackxmit (net/core/dev.c:4015:2) ipmcfinishoutput (net/ipv4/ipoutput.c:363:8) NFHOOK (./include/linux/netfilter.h:314:9) ipmcoutput (net/ipv4/ipoutput.c:400:5) dstoutput (./include/net/dst.h:459:9) iplocalout (net/ipv4/ipoutput.c:130:9) ipsendskb (net/ipv4/ipoutput.c:1496:8) udpsendskb (net/ipv4/udp.c:1040:8) udp_sendmsg (net/ipv4/udp.c:1328:10)
The output interface has a 4->6 program attached at ingress. We try to loop the multicast skb back to the sending socket. Ingress BPF runs as part of netifrx(), pushes a valid v6 hdr and changes skb->protocol to v6. We enter ip6rcvcore which tries to use skbdst(). But the dst is still an IPv4 one left after IPv4 mcast output.
Clear the dst in all BPF helpers which change the protocol. Try to preserve metadata dsts, those may carry non-routing metadata.