netfilter: ctnetlink: reject new conntrack request with different l4proto
authorLiping Zhang <liping.zhang@spreadtrum.com>
Mon, 8 Aug 2016 14:10:26 +0000 (22:10 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 9 Aug 2016 08:39:26 +0000 (10:39 +0200)
Currently, user can add a conntrack with different l4proto via nfnetlink.
For example, original tuple is TCP while reply tuple is SCTP. This is
invalid combination, we should report EINVAL to userspace.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_netlink.c

index b9bfe64..fdfc71f 100644 (file)
@@ -1894,6 +1894,8 @@ static int ctnetlink_new_conntrack(struct net *net, struct sock *ctnl,
 
                        if (!cda[CTA_TUPLE_ORIG] || !cda[CTA_TUPLE_REPLY])
                                return -EINVAL;
+                       if (otuple.dst.protonum != rtuple.dst.protonum)
+                               return -EINVAL;
 
                        ct = ctnetlink_create_conntrack(net, &zone, cda, &otuple,
                                                        &rtuple, u3);