nf_tables updates for net-next
Subsystems (4)
Pablo Neira Ayuso
maintainercover nf_tables updates for net-next
Hi David,
This batch contains fives nf_tables patches for your net-next tree, they are:
* Fix possible use after free in the module removal path of the x_tables compatibility layer, from Dan Carpenter.
* Add filter chain type for the bridge family, from myself.
* Fix Kconfig dependencies of the nf_tables bridge family with the core, from myself.
* Fix sparse warnings in nft_nat, from Tomasz Bursztyka.
* Remove duplicated include in the IPv4 family support for nf_tables, from Wei Yongjun.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nftables.git master
Thanks!
----------------------------------------------------------------
The following changes since commit a5bb202b848c7962f942f81d93290a9ccdfb1a0f:
netdev: inet_timewait_sock.h missing semi-colon when KMEMCHECK is enabled (2013-10-17 15:56:53 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nftables.git master
for you to fetch changes up to c359c4157cf0d852387aff2f2d83fef039aadc2c:
netfilter: nft_compat: use _safe version of list_for_each (2013-11-04 22:58:30 +0100)
----------------------------------------------------------------
Dan Carpenter (1):
netfilter: nft_compat: use _safe version of list_for_each
Pablo Neira Ayuso (2):
netfilter: bridge: fix nf_tables bridge dependencies with main core
netfilter: bridge: nf_tables: add filter chain type
Tomasz Bursztyka (1):
netfilter: nft_nat: Fix endianness issue reported by sparse
Wei Yongjun (1):
netfilter: nf_tables: remove duplicated include from nf_tables_ipv4.c
net/bridge/netfilter/Kconfig | 1 + net/bridge/netfilter/nf_tables_bridge.c | 41 +++++++++++++++++++++++++++++-- net/ipv4/netfilter/nf_tables_ipv4.c | 1 - net/netfilter/nft_compat.c | 8 +++--- net/netfilter/nft_nat.c | 12 ++++++--- 5 files changed, 52 insertions(+), 11 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/5 netfilter: bridge: fix nf_tables bridge dependencies with main core
when CONFIG_NF_TABLES[_MODULE] is not enabled,
but CONFIG_NF_TABLES_BRIDGE is enabled:
net/bridge/netfilter/nf_tables_bridge.c: In function 'nf_tables_bridge_init_net':net/bridge/netfilter/nf_tables_bridge.c:24:5: error: 'struct net' has no member named 'nft' net/bridge/netfilter/nf_tables_bridge.c:25:9: error: 'struct net' has no member named 'nft' net/bridge/netfilter/nf_tables_bridge.c:28:2: error: 'struct net' has no member named 'nft' net/bridge/netfilter/nf_tables_bridge.c:30:34: error: 'struct net' has no member named 'nft' net/bridge/netfilter/nf_tables_bridge.c:35:11: error: 'struct net' has no member named 'nft' net/bridge/netfilter/nf_tables_bridge.c: In function 'nf_tables_bridge_exit_net':net/bridge/netfilter/nf_tables_bridge.c:41:27: error: 'struct net' has no member named 'nft' net/bridge/netfilter/nf_tables_bridge.c:42:11: error: 'struct net' has no member named 'nft'
--- net/bridge/netfilter/Kconfig | 1 + 1 file changed, 1 insertion(+)
net/bridge/netfilter/Kconfig +1 -0
@@ -3,6 +3,7 @@ # # config NF_TABLES_BRIDGE + depends on NF_TABLES tristate "Ethernet Bridge nf_tables support" menuconfig BRIDGE_NF_EBTABLES
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 2/5 netfilter: nft_nat: Fix endianness issue reported by sparse
In reply to Pablo Neira AyusoFrom: Tomasz Bursztyka <[email protected]>
This patch fixes this:
CHECK net/netfilter/nft_nat.cnet/netfilter/nft_nat.c:50:43: warning: incorrect type in assignment (different base types)net/netfilter/nft_nat.c:50:43: expected restricted __be32 [addressable] [usertype] ipnet/netfilter/nft_nat.c:50:43: got unsigned int [unsigned] [usertype] <noident>net/netfilter/nft_nat.c:51:43: warning: incorrect type in assignment (different base types)net/netfilter/nft_nat.c:51:43: expected restricted __be32 [addressable] [usertype] ipnet/netfilter/nft_nat.c:51:43: got unsigned int [unsigned] [usertype] <noident>net/netfilter/nft_nat.c:65:37: warning: incorrect type in assignment (different base types)net/netfilter/nft_nat.c:65:37: expected restricted __be16 [addressable] [assigned] [usertype] allnet/netfilter/nft_nat.c:65:37: got unsigned int [unsigned] <noident>net/netfilter/nft_nat.c:66:37: warning: incorrect type in assignment (different base types)net/netfilter/nft_nat.c:66:37: expected restricted __be16 [addressable] [assigned] [usertype] allnet/netfilter/nft_nat.c:66:37: got unsigned int [unsigned] <noident>
--- net/netfilter/nft_nat.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/netfilter/nft_nat.c +8 -4
@@ -47,8 +47,10 @@ static void nft_nat_eval(const struct nft_expr *expr,memset (&range,0 ,sizeof (range));if (priv->sreg_addr_min) {if (priv->family ==AF_INET ) { - range.min_addr.ip = data[priv->sreg_addr_min].data[0 ]; - range.max_addr.ip = data[priv->sreg_addr_max].data[0 ]; + range.min_addr.ip = (__force __be32 ) + data[priv->sreg_addr_min].data[0 ]; + range.max_addr.ip = (__force __be32 ) + data[priv->sreg_addr_max].data[0 ]; }else { memcpy(range.min_addr.ip6,
@@ -62,8 +64,10 @@ static void nft_nat_eval(const struct nft_expr *expr, }if (priv->sreg_proto_min) { - range.min_proto.all = data[priv->sreg_proto_min].data[0 ]; - range.max_proto.all = data[priv->sreg_proto_max].data[0 ]; + range.min_proto.all = (__force __be16 ) + data[priv->sreg_proto_min].data[0 ]; + range.max_proto.all = (__force __be16 ) + data[priv->sreg_proto_max].data[0 ]; range.flags |=NF_NAT_RANGE_PROTO_SPECIFIED ; }
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 3/5 netfilter: bridge: nf_tables: add filter chain type
In reply to Pablo Neira AyusoThis patch adds the filter chain type which is required to create filter chains in the bridge family from userspace.
--- net/bridge/netfilter/nf_tables_bridge.c | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
net/bridge/netfilter/nf_tables_bridge.c +39 -2
@@ -1,5 +1,6 @@/* * Copyright (c) 2008 Patrick McHardy <[email protected]> +* Copyright (c) 2013 Pablo Neira Ayuso <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -47,14 +48,50 @@ static struct pernet_operations nf_tables_bridge_net_ops = { .exit = nf_tables_bridge_exit_net, }; +static unsigned int +nft_do_chain_bridge (const struct nf_hook_ops *ops, +struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +int (*okfn)(struct sk_buff *)) +{ +struct nft_pktinfo pkt; + +nft_set_pktinfo (&pkt, ops, skb, in, out); + +return nft_do_chain_pktinfo (&pkt, ops); +} + +static struct nf_chain_type filter_bridge = { + .family =NFPROTO_BRIDGE , + .name ="filter" , + .type =NFT_CHAIN_T_DEFAULT , + .hook_mask = (1 <<NF_BR_LOCAL_IN ) | + (1 <<NF_BR_FORWARD ) | + (1 <<NF_BR_LOCAL_OUT ), + .fn = { + [NF_BR_LOCAL_IN ] = nft_do_chain_bridge, + [NF_BR_FORWARD ] = nft_do_chain_bridge, + [NF_BR_LOCAL_OUT ] = nft_do_chain_bridge, + }, +}; +static int __init nf_tables_bridge_init (void ) { -return register_pernet_subsys (&nf_tables_bridge_net_ops); +int ret; + +nft_register_chain_type (&filter_bridge); + ret =register_pernet_subsys (&nf_tables_bridge_net_ops); +if (ret <0 ) +nft_unregister_chain_type (&filter_bridge); + +return ret; } static void __exit nf_tables_bridge_exit(void) { -return unregister_pernet_subsys (&nf_tables_bridge_net_ops); +unregister_pernet_subsys (&nf_tables_bridge_net_ops); +nft_unregister_chain_type (&filter_bridge); }module_init (nf_tables_bridge_init);
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 4/5 netfilter: nf_tables: remove duplicated include from nf_tables_ipv4.c
In reply to Pablo Neira AyusoFrom: Wei Yongjun <[email protected]>
Remove duplicated include.
--- net/ipv4/netfilter/nf_tables_ipv4.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/netfilter/nf_tables_ipv4.c +0 -1
@@ -16,7 +16,6 @@#include <net/netfilter/nf_tables.h> #include <net/net_namespace.h> #include <net/ip.h> -#include <net/net_namespace.h> #include <net/netfilter/nf_tables_ipv4.h> static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 5/5 netfilter: nft_compat: use _safe version of list_for_each
In reply to Pablo Neira AyusoFrom: Dan Carpenter <[email protected]>
We need to use the _safe version of list_for_each_entry() here otherwise we have a use after free bug.
--- net/netfilter/nft_compat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nft_compat.c +4 -4
@@ -634,9 +634,9 @@ nft_match_select_ops(const struct nft_ctx *ctx,static void nft_match_release (void ) { -struct nft_xt *nft_match; +struct nft_xt *nft_match, *tmp; -list_for_each_entry (nft_match, &nft_match_list, head) +list_for_each_entry_safe (nft_match, tmp, &nft_match_list, head)kfree (nft_match); }
@@ -705,9 +705,9 @@ nft_target_select_ops(const struct nft_ctx *ctx,static void nft_target_release (void ) { -struct nft_xt *nft_target; +struct nft_xt *nft_target, *tmp; -list_for_each_entry (nft_target, &nft_target_list, head) +list_for_each_entry_safe (nft_target, tmp, &nft_target_list, head)kfree (nft_target); }
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Mon, 4 Nov 2013 23:05:16 +0100
Quoted 11 lines
This batch contains fives
nf_tablespatches for your net-next tree, they are:* Fix possible use after free in the module removal path of the
x_tablescompatibility layer, from Dan Carpenter.* Add filter chain type for the bridge family, from myself.
* Fix
Kconfigdependencies of thenf_tablesbridge family with the core, from myself.
Quoted 8 lines
* Fix sparse warnings in
nft_nat, from Tomasz Bursztyka.* Remove duplicated include in the IPv4 family support for
nf_tables, from Wei Yongjun.You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nftables.gitmaster
Also looks fine, pulled, thanks!