* [Patch stable] netfilter: clear skb->next in NF_HOOK_LIST()
@ 2020-11-21 3:43 Cong Wang
2020-11-21 22:22 ` Florian Westphal
0 siblings, 1 reply; 4+ messages in thread
From: Cong Wang @ 2020-11-21 3:43 UTC (permalink / raw)
To: netdev
Cc: Cong Wang, liuzx, Florian Westphal, Edward Cree, stable,
Greg Kroah-Hartman
From: Cong Wang <cong.wang@bytedance.com>
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
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
include/linux/netfilter.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 77ebb61faf48..4c0e6539effd 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);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch stable] netfilter: clear skb->next in NF_HOOK_LIST()
2020-11-21 3:43 [Patch stable] netfilter: clear skb->next in NF_HOOK_LIST() Cong Wang
@ 2020-11-21 22:22 ` Florian Westphal
2020-11-22 17:24 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2020-11-21 22:22 UTC (permalink / raw)
To: Cong Wang
Cc: netdev, Cong Wang, liuzx, Florian Westphal, Edward Cree, stable,
Greg Kroah-Hartman
Cong Wang <xiyou.wangcong@gmail.com> wrote:
> From: Cong Wang <cong.wang@bytedance.com>
>
> 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()").
Thanks Cong, agree with this change, afaics its applicable to 4.19.y and 5.4.y.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch stable] netfilter: clear skb->next in NF_HOOK_LIST()
2020-11-21 22:22 ` Florian Westphal
@ 2020-11-22 17:24 ` Sasha Levin
[not found] ` <tencent_6C31555D2B46173F013EA6CC@qq.com>
0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2020-11-22 17:24 UTC (permalink / raw)
To: Florian Westphal
Cc: Cong Wang, netdev, Cong Wang, liuzx, Edward Cree, stable,
Greg Kroah-Hartman
On Sat, Nov 21, 2020 at 11:22:49PM +0100, Florian Westphal wrote:
>Cong Wang <xiyou.wangcong@gmail.com> wrote:
>> From: Cong Wang <cong.wang@bytedance.com>
>>
>> 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()").
>
>Thanks Cong, agree with this change, afaics its applicable to 4.19.y and 5.4.y.
Queued for 5.4 and 4.19, thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch stable] netfilter: clear skb->next in NF_HOOK_LIST()
[not found] ` <tencent_6C31555D2B46173F013EA6CC@qq.com>
@ 2020-11-28 10:09 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2020-11-28 10:09 UTC (permalink / raw)
To: 刘志旭
Cc: Sasha Levin, Florian Westphal, Cong Wang, netdev, Cong Wang,
Edward Cree, stable
On Sat, Nov 28, 2020 at 05:09:18PM +0800, 刘志旭 wrote:
> I still didn't see this patch in stable queue yet. Since we've a working POC to panic the
> system (see https://bugzilla.kernel.org/show_bug.cgi?id=209823), I think it's necessary
> to merge this patch ASAP, thanks.
Odd, I don't think Sasha pushed out his patch queue. I've applied this
now, thanks.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-28 22:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-21 3:43 [Patch stable] netfilter: clear skb->next in NF_HOOK_LIST() Cong Wang
2020-11-21 22:22 ` Florian Westphal
2020-11-22 17:24 ` Sasha Levin
[not found] ` <tencent_6C31555D2B46173F013EA6CC@qq.com>
2020-11-28 10:09 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).