Message ID | 20220726192056.13497-2-fw@strlen.de (mailing list archive) |
---|---|
State | Accepted |
Commit | 99a63d36cb3ed5ca3aa6fcb64cffbeaf3b0fb164 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,1/3] netfilter: nf_queue: do not allow packet truncation below transport header offset | expand |
Hello: This series was applied to netdev/net.git (master) by Florian Westphal <fw@strlen.de>: On Tue, 26 Jul 2022 21:20:54 +0200 you wrote: > Domingo Dirutigliano and Nicola Guerrera report kernel panic when > sending nf_queue verdict with 1-byte nfta_payload attribute. > > The IP/IPv6 stack pulls the IP(v6) header from the packet after the > input hook. > > If user truncates the packet below the header size, this skb_pull() will > result in a malformed skb (skb->len < 0). > > [...] Here is the summary with links: - [net,1/3] netfilter: nf_queue: do not allow packet truncation below transport header offset https://git.kernel.org/netdev/net/c/99a63d36cb3e - [net,2/3] netfilter: nf_tables: add rescheduling points during loop detection walks https://git.kernel.org/netdev/net/c/81ea01066741 - [net,3/3] netfilter: nft_queue: only allow supported familes and hooks https://git.kernel.org/netdev/net/c/47f4f510ad58 You are awesome, thank you!
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index a364f8e5e698..87a9009d5234 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -843,11 +843,16 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum) } static int -nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e, int diff) +nfqnl_mangle(void *data, unsigned int data_len, struct nf_queue_entry *e, int diff) { struct sk_buff *nskb; if (diff < 0) { + unsigned int min_len = skb_transport_offset(e->skb); + + if (data_len < min_len) + return -EINVAL; + if (pskb_trim(e->skb, data_len)) return -ENOMEM; } else if (diff > 0) {