netfilter: nfnetlink_queue: Don't set random flag bits
Subsystems (2)
RFC PATCH 1/1 netfilter: nfnetlink_queue: Don't set random flag bits
Allow setting of only supported flag bits in queue->flags.
If this is OK, I can send a patch to add this flag to libnetfilter_queue too.
--- include/linux/netfilter/nfnetlink_queue.h | 2 ++ net/netfilter/nfnetlink_queue_core.c | 6 ++++++ 2 files changed, 8 insertions(+)
include/linux/netfilter/nfnetlink_queue.h +2 -0
@@ -96,4 +96,6 @@ enum nfqnl_attr_config {#define NFQA_CFG_F_FAIL_OPEN (1 << 0)#define NFQA_CFG_F_CONNTRACK (1 << 1) +#define NFQA_CFG_F_FLAGS_MAX (1 << 2) +#endif /* _NFNETLINK_QUEUE_H */
net/netfilter/nfnetlink_queue_core.c +6 -0
@@ -910,6 +910,12 @@ nfqnl_recv_config(struct sock *ctnl, str flags =ntohl (nla_get_be32 (nfqa[NFQA_CFG_FLAGS ])); mask =ntohl (nla_get_be32 (nfqa[NFQA_CFG_MASK ])); +if (flags >=NFQA_CFG_F_FLAGS_MAX ) { +/* flags has more bits than what is supported */ + ret = -EOPNOTSUPP ; + goto err_out_unlock; + } +spin_lock_bh (&queue->lock); queue->flags &= ~mask; queue->flags |= flags & mask;
Pablo Neira Ayuso
maintainerQuoted 1 line · Krishna Kumar
Allow setting of only supported flag bits in
queue->flags.
I have applied this with minor glitches, see below.
Quoted 2 lines
If this is OK, I can send a patch to add this flag to
libnetfilter_queuetoo.
Not sure what you mean with the patch for libnetfilter_queue. If you consider adding some checking in user-space, no need to do it. We have to fail back on the kernel to report this. So we don't need to update libnetfilter_queue if we get new flags supported.
Back to your patch...
include/linux/netfilter/nfnetlink_queue.h enum nfqnl_attr_config { · line 98
Quoted 13 lines
Signed-off-by Krishna Kumar <[email protected]>--- include/linux/netfilter/nfnetlink_queue.h | 2 ++ net/netfilter/nfnetlink_queue_core.c | 6 ++++++ 2 files changed, 8 insertions(+)diff -ruNp
org/include/linux/netfilter/nfnetlink_queue.hnew/include/linux/netfilter/nfnetlink_queue.hinclude/linux/netfilter/nfnetlink_queue.h +0
-0@@ -96,4 +96,6 @@ enum nfqnl_attr_config {#define NFQA_CFG_F_FAIL_OPEN (1 << 0)#define NFQA_CFG_F_CONNTRACK (1 << 1)
removed this extra space above.
include/linux/netfilter/nfnetlink_queue.h enum nfqnl_attr_config { · line 99
Quoted 1 line
include/linux/netfilter/nfnetlink_queue.h +1
-0+#define NFQA_CFG_F_FLAGS_MAX (1 << 2)
removed _FLAGS, it seems redundant to _F.
net/netfilter/nfnetlink_queue_core.c nfqnl_recv_config(struct sock *ctnl, str · line 914
Quoted 11 lines
include/linux/netfilter/nfnetlink_queue.h +1
-0+#endif /* _NFNETLINK_QUEUE_H */ diff -ruNp
org/net/netfilter/nfnetlink_queue_core.cnew/net/netfilter/nfnetlink_queue_core.cnet/netfilter/nfnetlink_queue_core.c +2
-0@@ -910,6 +910,12 @@ nfqnl_recv_config(struct sock *ctnl, str flags =ntohl (nla_get_be32 (nfqa[NFQA_CFG_FLAGS ])); mask =ntohl (nla_get_be32 (nfqa[NFQA_CFG_MASK ])); +if (flags >=NFQA_CFG_F_FLAGS_MAX ) { +/* flags has more bits than what is supported */
removed this comment, I think it's more or less evinder to the source code reader what this does.
Quoted 12 lines
net/netfilter/nfnetlink_queue_core.c +4
-1+ ret = -EOPNOTSUPP ; + goto err_out_unlock; + } +spin_lock_bh (&queue->lock); queue->flags &= ~mask; queue->flags |= flags & mask; --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