Skip to contentSkip to conversation

netfilter: expect: fix crash when putting uninited expectation

PATCH Applied Florian Westphal 3 participants 3 messages Jul 10, 2017 – Jul 17, 2017

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: expect: fix crash when putting uninited expectation

We crash in __nf_ct_expect_check, it calls nf_ct_remove_expect on the uninitialised expectation instead of existing one, so del_timer chokes on random memory address.

Fixes ec0e3f01114ad32711243 ("netfilter: nf_ct_expect: Add nf_ct_remove_expect()")
Cc Gao Feng <[email protected]>
---
 net/netfilter/nf_conntrack_expect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_expect.c +1 -1
index e03d16ed550d..899c2c36da13 100644
@@ -422,7 +422,7 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect)
 	h = nf_ct_expect_dst_hash(net, &expect->tuple);
 	hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) {
 		if (expect_matches(i, expect)) {
-			if (nf_ct_remove_expect(expect))
+			if (nf_ct_remove_expect(i))
 				break;
 		} else if (expect_clash(i, expect)) {
 			ret = -EBUSY;
Signature · 1 line
2.13.0
#1 lore raw
Quoted 24 lines

From: Florian Westphal [mailto:[email protected]]
Subject: [PATCH nf] netfilter: expect: fix crash when putting uninited expectation

We crash in __nf_ct_expect_check, it calls nf_ct_remove_expect on the uninitialised expectation instead of existing one, so del_timer chokes on random memory address.

Fixes ec0e3f01114ad32711243 ("netfilter: nf_ct_expect: Add

nf_ct_remove_expect()")

---
 net/netfilter/nf_conntrack_expect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_expect.c +0 -0
index e03d16ed550d..899c2c36da13 100644

net/netfilter/nf_conntrack_expect.c static inline int __nf_ct_expect_check(struct · line 426

Quoted 6 lines
net/netfilter/nf_conntrack_expect.c +1 -1
@@ -422,7 +422,7 @@ static inline int __nf_ct_expect_check(struct
 nf_conntrack_expect *expect)
 	h = nf_ct_expect_dst_hash(net, &expect->tuple);
 	hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) {
 		if (expect_matches(i, expect)) {
-			if (nf_ct_remove_expect(expect))
+			if (nf_ct_remove_expect(i))

Thanks your fix. It's a typo indeed.

Best Regards
Feng

Quoted 5 lines
net/netfilter/nf_conntrack_expect.c +0 -0
 				break;
 		} else if (expect_clash(i, expect)) {

ret = -EBUSY;
--
2.13.0

maintainer Applied
#2 lore raw
In reply to Florian Westphal
Quoted 3 lines · Florian Westphal

We crash in __nf_ct_expect_check, it calls nf_ct_remove_expect on the uninitialised expectation instead of existing one, so del_timer chokes on random memory address.

Applied, thanks.