提交 a6289139 编写于 作者: F Florian Westphal 提交者: Zheng Zengkai

netfilter: nf_queue: do not allow packet truncation below transport header offset

stable inclusion
from stable-v5.10.135
commit 440dccd80f627e0e11ceb0429e4cdab61857d17e
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5J9R4?from=project-issue
CVE: CVE-2022-36946

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=440dccd80f627e0e11ceb0429e4cdab61857d17e

--------------------------------

[ Upstream commit 99a63d36 ]

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

Fixes: 7af4cc3f ("[NETFILTER]: Add "nfnetlink_queue" netfilter queue handler over nfnetlink")
Reported-by: NDomingo Dirutigliano <pwnzer0tt1@proton.me>
Signed-off-by: NFlorian Westphal <fw@strlen.de>
Reviewed-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b59534be
...@@ -838,11 +838,16 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum) ...@@ -838,11 +838,16 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
} }
static int 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; struct sk_buff *nskb;
if (diff < 0) { 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)) if (pskb_trim(e->skb, data_len))
return -ENOMEM; return -ENOMEM;
} else if (diff > 0) { } else if (diff > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册