netfilter: nf_queue: fix NF_STOLEN skb leak redux
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: nf_queue: fix NF_STOLEN skb leak redux
A userspace listener may send (bogus) NF_STOLEN verdict, which causes skb leak.
This problem was previously fixed via 64507fdbc29c3a622180378210ecea8659b14e40 (netfilter:nf_queue: fix NF_STOLEN skb leak) but this had to be reverted because NF_STOLEN can also be returned by a netfilter hook when iterating the rules in nf_reinject.
This is complementary to commit fad54440438a7c231a6ae347738423cbabc936d9 (netfilter: avoid double free in nf_reinject).
---
One alternative would be to change ip(6)queue and nfqueue to fail with -EINVAL if userspace gives NF_STOLEN verdict. Thoughts?
net/netfilter/nf_queue.c +4 -0
@@ -267,6 +267,10 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)const struct nf_afinfo *afinfo;int err; +/* NF_STOLEN from userspace makes no sense, we must free packet */ +if (WARN_ONCE (verdict ==NF_STOLEN ,"bogus verdict NF_STOLEN\n" )) + verdict =NF_DROP ; +rcu_read_lock ();nf_queue_entry_release_refs (entry);
Signature · 1 line
1.7.3.4
Hello,
Quoted 25 lines · Florian Westphal
A userspace listener may send (bogus)
NF_STOLENverdict, which causes skb leak.This problem was previously fixed via
64507fdbc29c3a622180378210ecea8659b14e40(netfilter:nf_queue: fixNF_STOLENskb leak) but this had to be reverted becauseNF_STOLENcan also be returned by a netfilter hook when iterating the rules innf_reinject.This is complementary to commit
fad54440438a7c231a6ae347738423cbabc936d9(netfilter: avoid double free innf_reinject).Cc Julian Anastasov <[email protected]>Cc Eric Dumazet <[email protected]>Signed-off-by Florian Westphal <[email protected]>---
One alternative would be to change ip(6)queue and nfqueue to fail with-EINVALif userspace givesNF_STOLENverdict. Thoughts?net/netfilter/nf_queue.c +0
-0
net/netfilter/nf_queue.c void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) · line 273
Quoted 7 lines
net/netfilter/nf_queue.c +4
-0@@ -267,6 +267,10 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)const struct nf_afinfo *afinfo;int err; +/* NF_STOLEN from userspace makes no sense, we must free packet */ +if (WARN_ONCE (verdict ==NF_STOLEN ,"bogus verdict NF_STOLEN\n" )) + verdict =NF_DROP ; +
Good catch, thanks! Can you add some prefix to this
message such as KERN_WARNING "nf_queue: " ?
net/netfilter/nf_queue.c void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) · line 276
Quoted 3 lines
net/netfilter/nf_queue.c +0
-0rcu_read_lock ();nf_queue_entry_release_refs (entry);
Regards
--
Julian Anastasov <[email protected]>
2011/8/11 Florian Westphal <[email protected]>:
Quoted 12 lines
A userspace listener may send (bogus)
NF_STOLENverdict, which causes skb leak.This problem was previously fixed via
64507fdbc29c3a622180378210ecea8659b14e40(netfilter:nf_queue: fixNF_STOLENskb leak) but this had to be reverted becauseNF_STOLENcan also be returned by a netfilter hook when iterating the rules innf_reinject.This is complementary to commit
fad54440438a7c231a6ae347738423cbabc936d9(netfilter: avoid double free innf_reinject).
Quoted 7 lines
Cc Julian Anastasov <[email protected]>Cc Eric Dumazet <[email protected]>Signed-off-by Florian Westphal <[email protected]>---
One alternative would be to change ip(6)queue and nfqueue to fail with-EINVALif userspace givesNF_STOLENverdict. Thoughts?
Since userspace is not supposed to pass NF_STOLEN, this would be the correct fix.
Just a hint, no guarantees attached. ;)
Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Florian Westphal
maintainerQuoted 21 lines · Micha? Miros?aw
2011/8/11 Florian Westphal <[email protected]>:
Quoted 12 lines
A userspace listener may send (bogus)
NF_STOLENverdict, which causes skb leak.This problem was previously fixed via
64507fdbc29c3a622180378210ecea8659b14e40(netfilter:nf_queue: fixNF_STOLENskb leak) but this had to be reverted becauseNF_STOLENcan also be returned by a netfilter hook when iterating the rules innf_reinject.This is complementary to commit
fad54440438a7c231a6ae347738423cbabc936d9(netfilter: avoid double free innf_reinject).Quoted 7 lines
Cc Julian Anastasov <[email protected]>Cc Eric Dumazet <[email protected]>Signed-off-by Florian Westphal <[email protected]>---
One alternative would be to change ip(6)queue and nfqueue to fail with-EINVALif userspace givesNF_STOLENverdict. Thoughts?
Quoted 4 lines
Since userspace is not supposed to pass
NF_STOLEN, this would be the correct fix.Just a hint, no guarantees attached. ;)
Agreed, it makes more sense to reject it.
I'll wait for a few hours before submitting a patch.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html