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 comparison in bitmask .reduce, from Jeremy Sowden.
2) Missing GFP_KERNEL_ACCOUNT for dynamically allocated objects, from Vasily Averin.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit ad7da1ce5749c0eb4f09dd7e5510123be56f10fb:
net: lan966x: fix kernel oops on ioctl when I/F is down (2022-03-29 10:47:24 +0200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git HEAD
for you to fetch changes up to 42193ffd79bd3acd91bd947e53f3548a3661d0a1:
netfilter: nf_tables: memcg accounting for dynamically allocated objects (2022-04-05 11:55:46 +0200)
----------------------------------------------------------------
Jeremy Sowden (1):
netfilter: bitwise: fix reduce comparisons
Vasily Averin (1):
netfilter: nf_tables: memcg accounting for dynamically allocated objects
net/netfilter/nf_tables_api.c | 2 +- net/netfilter/nft_bitwise.c | 4 ++-- net/netfilter/nft_connlimit.c | 2 +- net/netfilter/nft_counter.c | 2 +- net/netfilter/nft_last.c | 2 +- net/netfilter/nft_limit.c | 2 +- net/netfilter/nft_quota.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: bitwise: fix reduce comparisons
From: Jeremy Sowden <[email protected]>
The nft_bitwise_reduce and nft_bitwise_fast_reduce functions should compare the bitwise operation in expr with the tracked operation associated with the destination register of expr. However, instead of being called on expr and track->regs[priv->dreg].selector, nft_expr_priv is called on expr twice, so both reduce functions return true even when the operations differ.
--- net/netfilter/nft_bitwise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_bitwise.c +2 -2
@@ -290,7 +290,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->sreg].num_reg == 0 && track->regs[priv->dreg].bitwise &&
@@ -442,7 +442,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
Signature · 1 line
2.30.2
Re: [PATCH net 1/2] netfilter: bitwise: fix reduce comparisons
This 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 10 lines · On Tue, 5 Apr 2022 12:09:22 +0200 you wrote:
From: Jeremy Sowden <[email protected]>
The
nft_bitwise_reduceandnft_bitwise_fast_reducefunctions should compare the bitwise operation inexprwith the tracked operation associated with the destination register ofexpr. However, instead of being called onexprandtrack->regs[priv->dreg].selector,nft_expr_privis called onexprtwice, so both reduce functions return true even when the operations differ.[...]
Here is the summary with links:
- [net,1/2] netfilter: bitwise: fix reduce comparisons
https://git.kernel.org/netdev/net/c/31818213170c - [net,2/2] netfilter: nf_tables: memcg accounting for dynamically allocated objects https://git.kernel.org/netdev/net/c/42193ffd79bd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nf_tables: memcg accounting for dynamically allocated objects
In reply to Pablo Neira AyusoFrom: Vasily Averin <[email protected]>
nft_*.c files whose NFT_EXPR_STATEFUL flag is set on need to use __GFP_ACCOUNT flag for objects that are dynamically allocated from the packet path.
Such objects are allocated inside nft_expr_ops->init() callbacks executed in task context while processing netlink messages.
In addition, this patch adds accounting to nft_set_elem_expr_clone() used for the same purposes.
--- net/netfilter/nf_tables_api.c | 2 +- net/netfilter/nft_connlimit.c | 2 +- net/netfilter/nft_counter.c | 2 +- net/netfilter/nft_last.c | 2 +- net/netfilter/nft_limit.c | 2 +- net/netfilter/nft_quota.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -5526,7 +5526,7 @@ int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set,int err, i, k;for (i =0 ; i < set->num_exprs; i++) { - expr =kzalloc (set->exprs[i]->ops->size,GFP_KERNEL ); + expr =kzalloc (set->exprs[i]->ops->size,GFP_KERNEL_ACCOUNT );if (!expr) goto err_expr;
net/netfilter/nft_connlimit.c +1 -1
@@ -77,7 +77,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx, invert = true; } - priv->list =kmalloc (sizeof (*priv->list),GFP_KERNEL ); + priv->list =kmalloc (sizeof (*priv->list),GFP_KERNEL_ACCOUNT );if (!priv->list)return -ENOMEM ;
net/netfilter/nft_counter.c +1 -1
@@ -62,7 +62,7 @@ static int nft_counter_do_init(const struct nlattr * const tb[],struct nft_counter __percpu *cpu_stats;struct nft_counter *this_cpu; - cpu_stats = alloc_percpu(struct nft_counter); + cpu_stats = alloc_percpu_gfp(struct nft_counter, GFP_KERNEL_ACCOUNT);if (cpu_stats ==NULL )return -ENOMEM ;
net/netfilter/nft_last.c +1 -1
@@ -30,7 +30,7 @@ static int nft_last_init(const struct nft_ctx *ctx, const struct nft_expr *expr,u64 last_jiffies;int err; - last =kzalloc (sizeof (*last),GFP_KERNEL ); + last =kzalloc (sizeof (*last),GFP_KERNEL_ACCOUNT );if (!last)return -ENOMEM ;
net/netfilter/nft_limit.c +1 -1
@@ -90,7 +90,7 @@ static int nft_limit_init(struct nft_limit_priv *priv, priv->rate); } - priv->limit =kmalloc (sizeof (*priv->limit),GFP_KERNEL ); + priv->limit =kmalloc (sizeof (*priv->limit),GFP_KERNEL_ACCOUNT );if (!priv->limit)return -ENOMEM ;
net/netfilter/nft_quota.c +1 -1
@@ -90,7 +90,7 @@ static int nft_quota_do_init(const struct nlattr * const tb[],return -EOPNOTSUPP ; } - priv->consumed =kmalloc (sizeof (*priv->consumed),GFP_KERNEL ); + priv->consumed =kmalloc (sizeof (*priv->consumed),GFP_KERNEL_ACCOUNT );if (!priv->consumed)return -ENOMEM ;
Signature · 1 line
2.30.2