netfilter: nfnetlink_queue: do not allow to set unsupported flag bits
authorKrishna Kumar <krkumar2@in.ibm.com>
Wed, 27 Jun 2012 00:59:56 +0000 (00:59 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Jul 2012 17:51:50 +0000 (19:51 +0200)
Allow setting of only supported flag bits in queue->flags.

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter/nfnetlink_queue.h
net/netfilter/nfnetlink_queue_core.c

index e0d8fd8d4d24c514b86e420c32972fb048f53e95..3b1c1360aedfffb906c0b90c52dfc86a5a26db25 100644 (file)
@@ -95,5 +95,6 @@ enum nfqnl_attr_config {
 /* Flags for NFQA_CFG_FLAGS */
 #define NFQA_CFG_F_FAIL_OPEN                   (1 << 0)
 #define NFQA_CFG_F_CONNTRACK                   (1 << 1)
+#define NFQA_CFG_F_MAX                         (1 << 2)
 
 #endif /* _NFNETLINK_QUEUE_H */
index a0b64920039decfeffdfbbe68cbb02c0f855cce3..c0496a55ad0ceffb5470872cadc83c218a4b70c9 100644 (file)
@@ -910,6 +910,11 @@ nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
                flags = ntohl(nla_get_be32(nfqa[NFQA_CFG_FLAGS]));
                mask = ntohl(nla_get_be32(nfqa[NFQA_CFG_MASK]));
 
+               if (flags >= NFQA_CFG_F_MAX) {
+                       ret = -EOPNOTSUPP;
+                       goto err_out_unlock;
+               }
+
                spin_lock_bh(&queue->lock);
                queue->flags &= ~mask;
                queue->flags |= flags & mask;