netfilter: ctnetlink: don't permit ct creation with random tuple
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: ctnetlink: don't permit ct creation with random tuple
Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.
Problem is that tuple.dst.dir will be random, too, which causes nf_ct_tuplehash_to_ctrack() to return garbage.
--- net/netfilter/nf_conntrack_netlink.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
net/netfilter/nf_conntrack_netlink.c +3 -0
@@ -1596,6 +1596,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,if (nlh->nlmsg_flags &NLM_F_CREATE ) {enum ip_conntrack_events events; +if (!cda[CTA_TUPLE_ORIG ] || + !cda[CTA_TUPLE_REPLY ]) +return -EINVAL ; ct =ctnetlink_create_conntrack (net, zone, cda, &otuple, &rtuple, u3);if (IS_ERR (ct))
Signature · 1 line
1.7.8.6
Pablo Neira Ayuso
maintainerQuoted 5 lines · Florian Westphal
Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.Problem is that tuple.dst.dir will be random, too, which causes
nf_ct_tuplehash_to_ctrack()to return garbage.
good catch.
Quoted 10 lines
Signed-off-by Florian Westphal <[email protected]>--- net/netfilter/nf_conntrack_netlink.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)net/netfilter/nf_conntrack_netlink.c +0
-0
net/netfilter/nf_conntrack_netlink.c ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb, · line 1601
Quoted 6 lines
net/netfilter/nf_conntrack_netlink.c +3
-0@@ -1596,6 +1596,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,if (nlh->nlmsg_flags &NLM_F_CREATE ) {enum ip_conntrack_events events; +if (!cda[CTA_TUPLE_ORIG ] || + !cda[CTA_TUPLE_REPLY ]) +return -EINVAL ;
I think that needs to be && instead of ||.
No need to resend the patch, I'll fix it and apply.
Thanks Florian.
Quoted 10 lines
net/netfilter/nf_conntrack_netlink.c +0
-0ct =ctnetlink_create_conntrack (net, zone, cda, &otuple, &rtuple, u3);if (IS_ERR (ct))Signature · 6 lines
1.7.8.6 -- 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 6 lines · Pablo Neira Ayuso
Quoted 5 lines · Florian Westphal
Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.Problem is that tuple.dst.dir will be random, too, which causes
nf_ct_tuplehash_to_ctrack()to return garbage.
[..]
Quoted 8 lines
Quoted 8 lines
net/netfilter/nf_conntrack_netlink.c +0
-0@@ -1596,6 +1596,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,if (nlh->nlmsg_flags &NLM_F_CREATE ) {enum ip_conntrack_events events;
Quoted 5 lines
net/netfilter/nf_conntrack_netlink.c ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb, · line 1601
Quoted 3 lines
net/netfilter/nf_conntrack_netlink.c +3
-0+if (!cda[CTA_TUPLE_ORIG ] || + !cda[CTA_TUPLE_REPLY ]) +return -EINVAL ;I think that needs to be && instead of ||.
Uh, maybe I'm too low on caffeine, but when a new conntrack is to be created, shouldn't userspace have to specify _both_ ORIG and REPLY?
Pablo Neira Ayuso
maintainerQuoted 24 lines · Florian Westphal
Quoted 6 lines · Pablo Neira Ayuso
Quoted 5 lines · Florian Westphal
Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.Problem is that tuple.dst.dir will be random, too, which causes
nf_ct_tuplehash_to_ctrack()to return garbage.[..]
Quoted 8 lines
Quoted 8 lines
net/netfilter/nf_conntrack_netlink.c +0
-0@@ -1596,6 +1596,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,if (nlh->nlmsg_flags &NLM_F_CREATE ) {enum ip_conntrack_events events;Quoted 5 lines
net/netfilter/nf_conntrack_netlink.c ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb, · line 1601
Quoted 3 lines
net/netfilter/nf_conntrack_netlink.c +3
-0+if (!cda[CTA_TUPLE_ORIG ] || + !cda[CTA_TUPLE_REPLY ]) +return -EINVAL ;I think that needs to be && instead of ||.
Quoted 3 lines
Uh, maybe I'm too low on caffeine, but when a new conntrack is to be created, shouldn't userspace have to specify _both_ ORIG and REPLY?
You're right, it's me who is low on caffeine. Sorry.
Quoted 5 lines · Florian Westphal
Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.Problem is that tuple.dst.dir will be random, too, which causes
nf_ct_tuplehash_to_ctrack()to return garbage.
Applied, thanks Florian.