netfilter: ipv6: nf_defrag: fix NULL deref panic
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: ipv6: nf_defrag: fix NULL deref panic
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).
---
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(-)
net/ipv6/netfilter/nf_conntrack_reasm.c +8 -5
@@ -441,11 +441,14 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devicreturn 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);
Signature · 1 line
2.4.10
Quoted 9 lines · Florian Westphal
Valdis reports NULL deref in
nf_ct_frag6_gather.
Problem is bogus use ofskb_queue_walk()-- we miss first skb in the list since we start withhead->nextinstead of head.In case the element we're looking for was
head->nextwe 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 whatskb_queue_walkexpects).
Applied, thanks Florian.