aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCong Wang <cong.wang@bytedance.com>2020-11-20 19:43:17 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-02 08:49:44 +0100
commit6ec51459df7117dbe9b1fef2174951f80877a850 (patch)
tree2fdba2da3264b1a0c24a458e5448688d38be5868
parentee791835b3ec78178ca4c592368fa26d48dea5fa (diff)
downloadlinux-6ec51459df7117dbe9b1fef2174951f80877a850.tar.gz
netfilter: clear skb->next in NF_HOOK_LIST()
NF_HOOK_LIST() uses list_del() to remove skb from the linked list, however, it is not sufficient as skb->next still points to other skb. We should just call skb_list_del_init() to clear skb->next, like the rest places which using skb list. This has been fixed in upstream by commit ca58fbe06c54 ("netfilter: add and use nf_hook_slow_list()"). Fixes: 9f17dbf04ddf ("netfilter: fix use-after-free in NF_HOOK_LIST") Reported-by: liuzx@knownsec.com Tested-by: liuzx@knownsec.com Cc: Florian Westphal <fw@strlen.de> Cc: Edward Cree <ecree@solarflare.com> Cc: stable@vger.kernel.org # between 4.19 and 5.4 Signed-off-by: Cong Wang <cong.wang@bytedance.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/linux/netfilter.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 77ebb61faf4863..4c0e6539effddb 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -316,7 +316,7 @@ NF_HOOK_LIST(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
INIT_LIST_HEAD(&sublist);
list_for_each_entry_safe(skb, next, head, list) {
- list_del(&skb->list);
+ skb_list_del_init(skb);
if (nf_hook(pf, hook, net, sk, skb, in, out, okfn) == 1)
list_add_tail(&skb->list, &sublist);
}