Skip to content

Commit 79a392a

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Florian Westphal says: ==================== netfilter: bugfixes for net The following set contains netfilter fixes for the *net* tree. Regressions (rc only): recent ebtables crash fix was incomplete, it added a memory leak. The patch to fix possible buffer overrun for BIG TCP in ftp conntrack tried to be too clever, we cannot re-use ct->lock: NAT engine might grab it again -> deadlock. Revert back to a global spinlock. Both from myself. Remove the documentation for the recently removed 'nf_conntrack_helper' sysctl as well, from Pablo Neira. The static_branch_inc() that guards the 'chain stats enabled' path needs to be deferred further, until the entire transaction was created. From Tetsuo Handa. Older bugs: Since 5.3: nf_tables_addchain may leak pcpu memory in error path when offloading fails. Also from Tetsuo Handa. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6a1dbfe + d250889 commit 79a392a

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

Documentation/networking/nf_conntrack-sysctl.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ nf_conntrack_generic_timeout - INTEGER (seconds)
7070
Default for generic timeout. This refers to layer 4 unknown/unsupported
7171
protocols.
7272

73-
nf_conntrack_helper - BOOLEAN
74-
- 0 - disabled (default)
75-
- not 0 - enabled
76-
77-
Enable automatic conntrack helper assignment.
78-
If disabled it is required to set up iptables rules to assign
79-
helpers to connections. See the CT target description in the
80-
iptables-extensions(8) man page for further information.
81-
8273
nf_conntrack_icmp_timeout - INTEGER (seconds)
8374
default 30
8475

net/bridge/netfilter/ebtables.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,10 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
10401040
goto free_iterate;
10411041
}
10421042

1043-
if (repl->valid_hooks != t->valid_hooks)
1043+
if (repl->valid_hooks != t->valid_hooks) {
1044+
ret = -EINVAL;
10441045
goto free_unlock;
1046+
}
10451047

10461048
if (repl->num_counters && repl->num_counters != t->private->nentries) {
10471049
ret = -EINVAL;

net/netfilter/nf_conntrack_ftp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ MODULE_AUTHOR("Rusty Russell <[email protected]>");
3333
MODULE_DESCRIPTION("ftp connection tracking helper");
3434
MODULE_ALIAS("ip_conntrack_ftp");
3535
MODULE_ALIAS_NFCT_HELPER(HELPER_NAME);
36+
static DEFINE_SPINLOCK(nf_ftp_lock);
3637

3738
#define MAX_PORTS 8
3839
static u_int16_t ports[MAX_PORTS];
@@ -409,7 +410,8 @@ static int help(struct sk_buff *skb,
409410
}
410411
datalen = skb->len - dataoff;
411412

412-
spin_lock_bh(&ct->lock);
413+
/* seqadj (nat) uses ct->lock internally, nf_nat_ftp would cause deadlock */
414+
spin_lock_bh(&nf_ftp_lock);
413415
fb_ptr = skb->data + dataoff;
414416

415417
ends_in_nl = (fb_ptr[datalen - 1] == '\n');
@@ -538,7 +540,7 @@ static int help(struct sk_buff *skb,
538540
if (ends_in_nl)
539541
update_nl_seq(ct, seq, ct_ftp_info, dir, skb);
540542
out:
541-
spin_unlock_bh(&ct->lock);
543+
spin_unlock_bh(&nf_ftp_lock);
542544
return ret;
543545
}
544546

net/netfilter/nf_tables_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
21972197
struct netlink_ext_ack *extack)
21982198
{
21992199
const struct nlattr * const *nla = ctx->nla;
2200-
struct nft_stats __percpu *stats = NULL;
22012200
struct nft_table *table = ctx->table;
22022201
struct nft_base_chain *basechain;
22032202
struct net *net = ctx->net;
@@ -2212,6 +2211,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
22122211
return -EOVERFLOW;
22132212

22142213
if (nla[NFTA_CHAIN_HOOK]) {
2214+
struct nft_stats __percpu *stats = NULL;
22152215
struct nft_chain_hook hook;
22162216

22172217
if (flags & NFT_CHAIN_BINDING)
@@ -2243,8 +2243,11 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
22432243
if (err < 0) {
22442244
nft_chain_release_hook(&hook);
22452245
kfree(basechain);
2246+
free_percpu(stats);
22462247
return err;
22472248
}
2249+
if (stats)
2250+
static_branch_inc(&nft_counters_enabled);
22482251
} else {
22492252
if (flags & NFT_CHAIN_BASE)
22502253
return -EINVAL;
@@ -2319,9 +2322,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
23192322
goto err_unregister_hook;
23202323
}
23212324

2322-
if (stats)
2323-
static_branch_inc(&nft_counters_enabled);
2324-
23252325
table->use++;
23262326

23272327
return 0;

0 commit comments

Comments
 (0)