diff options
author | David S. Miller <davem@davemloft.net> | 2013-12-29 00:24:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-29 00:24:28 -0500 |
commit | a72338a00ed19f68bb08a1b46dad5a315e562ed9 (patch) | |
tree | b611bf5c2f284f0423fde24ac5c8692c03135f68 | |
parent | 6a9eadccff2926e392173a989042f14c867cffbf (diff) | |
parent | 2ee0d3c80fdb7974cfa1c7e25b5048e9fcaf69b6 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says:
====================
Netfilter/IPVS fixes for net
This patchset contains four nf_tables fixes, one IPVS fix due to
missing updates in the interaction with the new sedadj conntrack
extension that was added to support the netfilter synproxy code,
and a couple of one-liners to fix netnamespace netfilter issues.
More specifically, they are:
* Fix ipv6_find_hdr() call without offset being explicitly initialized
in nft_exthdr, as required by that function, from Daniel Borkmann.
* Fix oops in nfnetlink_log when using netns and unloading the kernel
module, from Gao feng.
* Fix BUG_ON in nf_ct_timestamp extension after netns is destroyed,
from Helmut Schaa.
* Fix crash in IPVS due to missing sequence adjustment extension being
allocated in the conntrack, from Jesper Dangaard Brouer.
* Add bugtrap to spot a warning in case you deference sequence adjustment
conntrack area when not available, this should help to catch similar
invalid dereferences in the Netfilter tree, also from Jesper.
* Fix incomplete dumping of sets in nf_tables when retrieving by family,
from me.
* Fix oops when updating the table state (dormant <-> active) and having
user (not base ) chains, from me.
* Fix wrong validation in set element data that results in returning
-EINVAL when using the nf_tables dictionary feature with mappings,
also from me.
We don't usually have this amount of fixes by this time (as we're already
in -rc5 of the development cycle), although half of them are related to
nf_tables which is a relatively new thing, and I also believe that holidays
have also delayed the flight of bugfixes to mainstream a bit.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/netfilter/ipvs/ip_vs_nfct.c | 6 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_seqadj.c | 5 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_timestamp.c | 1 | ||||
-rw-r--r-- | net/netfilter/nf_tables_api.c | 26 | ||||
-rw-r--r-- | net/netfilter/nfnetlink_log.c | 1 | ||||
-rw-r--r-- | net/netfilter/nft_exthdr.c | 2 |
6 files changed, 33 insertions, 8 deletions
diff --git a/net/netfilter/ipvs/ip_vs_nfct.c b/net/netfilter/ipvs/ip_vs_nfct.c index c8beafd401aa..5a355a46d1dc 100644 --- a/net/netfilter/ipvs/ip_vs_nfct.c +++ b/net/netfilter/ipvs/ip_vs_nfct.c | |||
@@ -63,6 +63,7 @@ | |||
63 | #include <net/ip_vs.h> | 63 | #include <net/ip_vs.h> |
64 | #include <net/netfilter/nf_conntrack_core.h> | 64 | #include <net/netfilter/nf_conntrack_core.h> |
65 | #include <net/netfilter/nf_conntrack_expect.h> | 65 | #include <net/netfilter/nf_conntrack_expect.h> |
66 | #include <net/netfilter/nf_conntrack_seqadj.h> | ||
66 | #include <net/netfilter/nf_conntrack_helper.h> | 67 | #include <net/netfilter/nf_conntrack_helper.h> |
67 | #include <net/netfilter/nf_conntrack_zones.h> | 68 | #include <net/netfilter/nf_conntrack_zones.h> |
68 | 69 | ||
@@ -97,6 +98,11 @@ ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, int outin) | |||
97 | if (CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) | 98 | if (CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) |
98 | return; | 99 | return; |
99 | 100 | ||
101 | /* Applications may adjust TCP seqs */ | ||
102 | if (cp->app && nf_ct_protonum(ct) == IPPROTO_TCP && | ||
103 | !nfct_seqadj(ct) && !nfct_seqadj_ext_add(ct)) | ||
104 | return; | ||
105 | |||
100 | /* | 106 | /* |
101 | * The connection is not yet in the hashtable, so we update it. | 107 | * The connection is not yet in the hashtable, so we update it. |
102 | * CIP->VIP will remain the same, so leave the tuple in | 108 | * CIP->VIP will remain the same, so leave the tuple in |
diff --git a/net/netfilter/nf_conntrack_seqadj.c b/net/netfilter/nf_conntrack_seqadj.c index 17c1bcb182c6..b2d38da67822 100644 --- a/net/netfilter/nf_conntrack_seqadj.c +++ b/net/netfilter/nf_conntrack_seqadj.c | |||
@@ -36,6 +36,11 @@ int nf_ct_seqadj_set(struct nf_conn *ct, enum ip_conntrack_info ctinfo, | |||
36 | if (off == 0) | 36 | if (off == 0) |
37 | return 0; | 37 | return 0; |
38 | 38 | ||
39 | if (unlikely(!seqadj)) { | ||
40 | WARN(1, "Wrong seqadj usage, missing nfct_seqadj_ext_add()\n"); | ||
41 | return 0; | ||
42 | } | ||
43 | |||
39 | set_bit(IPS_SEQ_ADJUST_BIT, &ct->status); | 44 | set_bit(IPS_SEQ_ADJUST_BIT, &ct->status); |
40 | 45 | ||
41 | spin_lock_bh(&ct->lock); | 46 | spin_lock_bh(&ct->lock); |
diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c index 902fb0a6b38a..7a394df0deb7 100644 --- a/net/netfilter/nf_conntrack_timestamp.c +++ b/net/netfilter/nf_conntrack_timestamp.c | |||
@@ -97,7 +97,6 @@ int nf_conntrack_tstamp_pernet_init(struct net *net) | |||
97 | void nf_conntrack_tstamp_pernet_fini(struct net *net) | 97 | void nf_conntrack_tstamp_pernet_fini(struct net *net) |
98 | { | 98 | { |
99 | nf_conntrack_tstamp_fini_sysctl(net); | 99 | nf_conntrack_tstamp_fini_sysctl(net); |
100 | nf_ct_extend_unregister(&tstamp_extend); | ||
101 | } | 100 | } |
102 | 101 | ||
103 | int nf_conntrack_tstamp_init(void) | 102 | int nf_conntrack_tstamp_init(void) |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index f93b7d06f4be..71a9f49a768b 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
@@ -312,6 +312,9 @@ static int nf_tables_table_enable(struct nft_table *table) | |||
312 | int err, i = 0; | 312 | int err, i = 0; |
313 | 313 | ||
314 | list_for_each_entry(chain, &table->chains, list) { | 314 | list_for_each_entry(chain, &table->chains, list) { |
315 | if (!(chain->flags & NFT_BASE_CHAIN)) | ||
316 | continue; | ||
317 | |||
315 | err = nf_register_hook(&nft_base_chain(chain)->ops); | 318 | err = nf_register_hook(&nft_base_chain(chain)->ops); |
316 | if (err < 0) | 319 | if (err < 0) |
317 | goto err; | 320 | goto err; |
@@ -321,6 +324,9 @@ static int nf_tables_table_enable(struct nft_table *table) | |||
321 | return 0; | 324 | return 0; |
322 | err: | 325 | err: |
323 | list_for_each_entry(chain, &table->chains, list) { | 326 | list_for_each_entry(chain, &table->chains, list) { |
327 | if (!(chain->flags & NFT_BASE_CHAIN)) | ||
328 | continue; | ||
329 | |||
324 | if (i-- <= 0) | 330 | if (i-- <= 0) |
325 | break; | 331 | break; |
326 | 332 | ||
@@ -333,8 +339,10 @@ static int nf_tables_table_disable(struct nft_table *table) | |||
333 | { | 339 | { |
334 | struct nft_chain *chain; | 340 | struct nft_chain *chain; |
335 | 341 | ||
336 | list_for_each_entry(chain, &table->chains, list) | 342 | list_for_each_entry(chain, &table->chains, list) { |
337 | nf_unregister_hook(&nft_base_chain(chain)->ops); | 343 | if (chain->flags & NFT_BASE_CHAIN) |
344 | nf_unregister_hook(&nft_base_chain(chain)->ops); | ||
345 | } | ||
338 | 346 | ||
339 | return 0; | 347 | return 0; |
340 | } | 348 | } |
@@ -2098,17 +2106,21 @@ static int nf_tables_dump_sets_all(struct nft_ctx *ctx, struct sk_buff *skb, | |||
2098 | struct netlink_callback *cb) | 2106 | struct netlink_callback *cb) |
2099 | { | 2107 | { |
2100 | const struct nft_set *set; | 2108 | const struct nft_set *set; |
2101 | unsigned int idx = 0, s_idx = cb->args[0]; | 2109 | unsigned int idx, s_idx = cb->args[0]; |
2102 | struct nft_table *table, *cur_table = (struct nft_table *)cb->args[2]; | 2110 | struct nft_table *table, *cur_table = (struct nft_table *)cb->args[2]; |
2103 | 2111 | ||
2104 | if (cb->args[1]) | 2112 | if (cb->args[1]) |
2105 | return skb->len; | 2113 | return skb->len; |
2106 | 2114 | ||
2107 | list_for_each_entry(table, &ctx->afi->tables, list) { | 2115 | list_for_each_entry(table, &ctx->afi->tables, list) { |
2108 | if (cur_table && cur_table != table) | 2116 | if (cur_table) { |
2109 | continue; | 2117 | if (cur_table != table) |
2118 | continue; | ||
2110 | 2119 | ||
2120 | cur_table = NULL; | ||
2121 | } | ||
2111 | ctx->table = table; | 2122 | ctx->table = table; |
2123 | idx = 0; | ||
2112 | list_for_each_entry(set, &ctx->table->sets, list) { | 2124 | list_for_each_entry(set, &ctx->table->sets, list) { |
2113 | if (idx < s_idx) | 2125 | if (idx < s_idx) |
2114 | goto cont; | 2126 | goto cont; |
@@ -2370,7 +2382,9 @@ static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx, | |||
2370 | enum nft_registers dreg; | 2382 | enum nft_registers dreg; |
2371 | 2383 | ||
2372 | dreg = nft_type_to_reg(set->dtype); | 2384 | dreg = nft_type_to_reg(set->dtype); |
2373 | return nft_validate_data_load(ctx, dreg, &elem->data, set->dtype); | 2385 | return nft_validate_data_load(ctx, dreg, &elem->data, |
2386 | set->dtype == NFT_DATA_VERDICT ? | ||
2387 | NFT_DATA_VERDICT : NFT_DATA_VALUE); | ||
2374 | } | 2388 | } |
2375 | 2389 | ||
2376 | int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, | 2390 | int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, |
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index 3c4b69e5fe17..a155d19a225e 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c | |||
@@ -1053,6 +1053,7 @@ static void __net_exit nfnl_log_net_exit(struct net *net) | |||
1053 | #ifdef CONFIG_PROC_FS | 1053 | #ifdef CONFIG_PROC_FS |
1054 | remove_proc_entry("nfnetlink_log", net->nf.proc_netfilter); | 1054 | remove_proc_entry("nfnetlink_log", net->nf.proc_netfilter); |
1055 | #endif | 1055 | #endif |
1056 | nf_log_unset(net, &nfulnl_logger); | ||
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | static struct pernet_operations nfnl_log_net_ops = { | 1059 | static struct pernet_operations nfnl_log_net_ops = { |
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c index 8e0bb75e7c51..55c939f5371f 100644 --- a/net/netfilter/nft_exthdr.c +++ b/net/netfilter/nft_exthdr.c | |||
@@ -31,7 +31,7 @@ static void nft_exthdr_eval(const struct nft_expr *expr, | |||
31 | { | 31 | { |
32 | struct nft_exthdr *priv = nft_expr_priv(expr); | 32 | struct nft_exthdr *priv = nft_expr_priv(expr); |
33 | struct nft_data *dest = &data[priv->dreg]; | 33 | struct nft_data *dest = &data[priv->dreg]; |
34 | unsigned int offset; | 34 | unsigned int offset = 0; |
35 | int err; | 35 | int err; |
36 | 36 | ||
37 | err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL); | 37 | err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL); |