Netfilter fixes for net
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi,
The following patchset contains Netfilter fixes for net:
1) Incorrect helper module alias in netbios_ns, from Florian Westphal.
2) Remove unused variable in nf_tables.
3) Uninitialized last expression in nf_tables register tracking.
4) Memleak in nft_connlimit after moving stateful data out of the expression data area.
5) Bogus invalid stats update when NF_REPEAT is returned, from Florian.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit 7d6019b602de660bfc6a542a68630006ace83b90:
Revert "net: vertexcom: default to disabled on kbuild" (2022-01-10 21:11:07 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 830af2eba40327abec64325a5b08b1e85c37a2e0:
netfilter: conntrack: don't increment invalid counter on NF_REPEAT (2022-01-16 00:55:27 +0100)
----------------------------------------------------------------
Florian Westphal (2):
netfilter: nf_conntrack_netbios_ns: fix helper module alias
netfilter: conntrack: don't increment invalid counter on NF_REPEAT
Pablo Neira Ayuso (3):
netfilter: nf_tables: remove unused variable
netfilter: nf_tables: set last expression in register tracking area
netfilter: nft_connlimit: memleak if nf_ct_netns_get() fails
net/netfilter/nf_conntrack_core.c | 8 +++++--- net/netfilter/nf_conntrack_netbios_ns.c | 5 +++-- net/netfilter/nf_tables_api.c | 4 +--- net/netfilter/nft_connlimit.c | 11 ++++++++++- 4 files changed, 19 insertions(+), 9 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 4/5 netfilter: nft_connlimit: memleak if nf_ct_netns_get() fails
Check if nf_ct_netns_get() fails then release the limit object previously allocated via kmalloc().
--- net/netfilter/nft_connlimit.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
net/netfilter/nft_connlimit.c +10 -1
@@ -62,6 +62,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx, {bool invert = false;u32 flags, limit; +int err;if (!tb[NFTA_CONNLIMIT_COUNT ])return -EINVAL ;
@@ -84,7 +85,15 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx, priv->limit = limit; priv->invert = invert; -return nf_ct_netns_get (ctx->net, ctx->family); + err =nf_ct_netns_get (ctx->net, ctx->family); +if (err <0 ) + goto err_netns; + +return 0 ; +err_netns: +kfree (priv->list); + +return err; } static void nft_connlimit_do_destroy(const struct nft_ctx *ctx,
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 1/5 netfilter: nf_conntrack_netbios_ns: fix helper module alias
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
The helper gets registered as 'netbios-ns', not netbios_ns. Intentionally not adding a fixes-tag because i don't want this to go to stable. This wasn't noticed for a very long time so no so no need to risk regressions.
--- net/netfilter/nf_conntrack_netbios_ns.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_netbios_ns.c +3 -2
@@ -20,13 +20,14 @@#include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_expect.h> +#define HELPER_NAME "netbios-ns"#define NMBD_PORT 137MODULE_AUTHOR ("Patrick McHardy <[email protected]>" );MODULE_DESCRIPTION ("NetBIOS name service broadcast connection tracking helper" );MODULE_LICENSE ("GPL" );MODULE_ALIAS ("ip_conntrack_netbios_ns" ); -MODULE_ALIAS_NFCT_HELPER ("netbios_ns" ); +MODULE_ALIAS_NFCT_HELPER (HELPER_NAME );static unsigned int timeout__read_mostly =3 ;module_param (timeout, uint,0400 );
@@ -44,7 +45,7 @@ static int netbios_ns_help(struct sk_buff *skb, unsigned int protoff, }static struct nf_conntrack_helper helper__read_mostly = { - .name ="netbios-ns" , + .name =HELPER_NAME , .tuple.src.l3num =NFPROTO_IPV4 , .tuple.src.u.udp.port =cpu_to_be16 (NMBD_PORT ), .tuple.dst.protonum =IPPROTO_UDP ,
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 5/5 netfilter: conntrack: don't increment invalid counter on NF_REPEAT
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
The packet isn't invalid, REPEAT means we're trying again after cleaning out a stale connection, e.g. via tcp tracker.
This caused increases of invalid stat counter in a test case involving frequent connection reuse, even though no packet is actually invalid.
--- net/netfilter/nf_conntrack_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_core.c +5 -3
@@ -1924,15 +1924,17 @@ nf_conntrack_in(struct sk_buff *skb, const struct nf_hook_state *state)pr_debug ("nf_conntrack_in: Can't track with proto module\n" );nf_ct_put (ct); skb->_nfct =0 ; -NF_CT_STAT_INC_ATOMIC (state->net, invalid); -if (ret == -NF_DROP ) -NF_CT_STAT_INC_ATOMIC (state->net, drop);/* Special case: TCP tracker reports an attempt to reopen a * closed/aborted connection. We have to go back and create a * fresh conntrack. */ if (ret == -NF_REPEAT ) goto repeat; + +NF_CT_STAT_INC_ATOMIC (state->net, invalid); +if (ret == -NF_DROP ) +NF_CT_STAT_INC_ATOMIC (state->net, drop); + ret = -ret; goto out; }
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 2/5 netfilter: nf_tables: remove unused variable
In reply to Pablo Neira AyusoQuoted 5 lines
Remove unused variable and fix missing initialization.
Quoted 1 line
Quoted 1 line
net/netfilter/nf_tables_api.c:8266:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]int i; ^
--- net/netfilter/nf_tables_api.c | 2 -- 1 file changed, 2 deletions(-)
net/netfilter/nf_tables_api.c +0 -2
@@ -8264,14 +8264,12 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *chavoid *data, *data_boundary;struct nft_rule_dp *prule;struct nft_rule *rule; -int i;/* already handled or inactive chain? */ if (chain->blob_next || !nft_is_active_next (net, chain))return 0 ; rule = list_entry(&chain->rules, struct nft_rule, list); - i =0 ; data_size =0 ;list_for_each_entry_continue (rule, &chain->rules, list) {
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 3/5 netfilter: nf_tables: set last expression in register tracking area
In reply to Pablo Neira Ayusonft_rule_for_each_expr() sets on last to nft_rule_last(), however, this is coming after track.last field is set on.
Use nft_expr_last() to set track.last accordingly.
--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -8299,7 +8299,7 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *chareturn -ENOMEM ; size =0 ; - track.last = last; + track.last =nft_expr_last (rule);nft_rule_for_each_expr (expr, last, rule) { track.cur = expr;
Signature · 1 line
2.30.2
Re: [PATCH net 1/5] netfilter: nf_conntrack_netbios_ns: fix helper module alias
In reply to Pablo Neira AyusoThis series was applied to netdev/net.git (master) by Pablo Neira Ayuso <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Pablo Neira Ayuso <[email protected]>:
Quoted 8 lines · On Thu, 20 Jan 2022 13:52:08 +0100 you wrote:
From: Florian Westphal <[email protected]>
The helper gets registered as 'netbios-ns', not
netbios_ns. Intentionally not adding a fixes-tag because i don't want this to go to stable. This wasn't noticed for a very long time so no so no need to risk regressions.[...]
Here is the summary with links:
- [net,1/5] netfilter: nf_conntrack_netbios_ns: fix helper module alias
https://git.kernel.org/netdev/net/c/0e906607b9c5 - [net,2/5] netfilter: nf_tables: remove unused variable https://git.kernel.org/netdev/net/c/cf46eacbc156 - [net,3/5] netfilter: nf_tables: set last expression in register tracking area https://git.kernel.org/netdev/net/c/fe75e84a8fe1 - [net,4/5] netfilter: nft_connlimit: memleak if nf_ct_netns_get() fails https://git.kernel.org/netdev/net/c/7d70984a1ad4 - [net,5/5] netfilter: conntrack: don't increment invalid counter on NF_REPEAT https://git.kernel.org/netdev/net/c/830af2eba403
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html