* [PATCH nf-next] netfilter: ipv6: nf_defrag: fix NULL deref panic
@ 2015-12-08 22:35 Florian Westphal
2015-12-09 13:27 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2015-12-08 22:35 UTC (permalink / raw)
To: netfilter-devel; +Cc: Valdis.Kletnieks, Florian Westphal
Valdis reports NULL deref in nf_ct_frag6_gather.
Problem is bogus use of skb_queue_walk() -- we miss first skb in the list
since we start with head->next instead of head.
In case the element we're looking for was head->next we won't find
a result and then trip over NULL iter.
(defrag uses plain NULL-terminated list rather than one terminated by
head-of-list-pointer, which is what skb_queue_walk expects).
Fixes: 029f7f3b8701cc7a ("netfilter: ipv6: nf_defrag: avoid/free clone operations")
Reported-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Tested-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
nf-next since the faulty commit is only present there.
net/ipv6/netfilter/nf_conntrack_reasm.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 912bc3a..6e5f0e0d 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -441,11 +441,14 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devic
return false;
fp->next = prev->next;
- skb_queue_walk(head, iter) {
- if (iter->next != prev)
- continue;
- iter->next = fp;
- break;
+
+ iter = head;
+ while (iter) {
+ if (iter->next == prev) {
+ iter->next = fp;
+ break;
+ }
+ iter = iter->next;
}
skb_morph(prev, head);
--
2.4.10
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf-next] netfilter: ipv6: nf_defrag: fix NULL deref panic
2015-12-08 22:35 [PATCH nf-next] netfilter: ipv6: nf_defrag: fix NULL deref panic Florian Westphal
@ 2015-12-09 13:27 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2015-12-09 13:27 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel, Valdis.Kletnieks
On Tue, Dec 08, 2015 at 11:35:19PM +0100, Florian Westphal wrote:
> Valdis reports NULL deref in nf_ct_frag6_gather.
> Problem is bogus use of skb_queue_walk() -- we miss first skb in the list
> since we start with head->next instead of head.
>
> In case the element we're looking for was head->next we won't find
> a result and then trip over NULL iter.
>
> (defrag uses plain NULL-terminated list rather than one terminated by
> head-of-list-pointer, which is what skb_queue_walk expects).
Applied, thanks Florian.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-09 13:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-08 22:35 [PATCH nf-next] netfilter: ipv6: nf_defrag: fix NULL deref panic Florian Westphal
2015-12-09 13:27 ` Pablo Neira Ayuso
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).