Commit 03eb7dae authored by Jakub Kicinski's avatar Jakub Kicinski

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf

Pablo Neira Ayuso says:

====================
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.

* git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf:
  netfilter: nf_tables: memcg accounting for dynamically allocated objects
  netfilter: bitwise: fix reduce comparisons
====================

Link: https://lore.kernel.org/r/20220405100923.7231-1-pablo@netfilter.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 1158f79f 42193ffd
...@@ -5526,7 +5526,7 @@ int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set, ...@@ -5526,7 +5526,7 @@ int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set,
int err, i, k; int err, i, k;
for (i = 0; i < set->num_exprs; i++) { 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) if (!expr)
goto err_expr; goto err_expr;
......
...@@ -290,7 +290,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track, ...@@ -290,7 +290,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track,
if (!track->regs[priv->sreg].selector) if (!track->regs[priv->sreg].selector)
return false; 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 && if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector &&
track->regs[priv->sreg].num_reg == 0 && track->regs[priv->sreg].num_reg == 0 &&
track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise &&
...@@ -442,7 +442,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_track *track, ...@@ -442,7 +442,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_track *track,
if (!track->regs[priv->sreg].selector) if (!track->regs[priv->sreg].selector)
return false; 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 && if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector &&
track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise &&
track->regs[priv->dreg].bitwise->ops == expr->ops && track->regs[priv->dreg].bitwise->ops == expr->ops &&
......
...@@ -77,7 +77,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx, ...@@ -77,7 +77,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx,
invert = true; invert = true;
} }
priv->list = kmalloc(sizeof(*priv->list), GFP_KERNEL); priv->list = kmalloc(sizeof(*priv->list), GFP_KERNEL_ACCOUNT);
if (!priv->list) if (!priv->list)
return -ENOMEM; return -ENOMEM;
......
...@@ -62,7 +62,7 @@ static int nft_counter_do_init(const struct nlattr * const tb[], ...@@ -62,7 +62,7 @@ static int nft_counter_do_init(const struct nlattr * const tb[],
struct nft_counter __percpu *cpu_stats; struct nft_counter __percpu *cpu_stats;
struct nft_counter *this_cpu; 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) if (cpu_stats == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -30,7 +30,7 @@ static int nft_last_init(const struct nft_ctx *ctx, const struct nft_expr *expr, ...@@ -30,7 +30,7 @@ static int nft_last_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
u64 last_jiffies; u64 last_jiffies;
int err; int err;
last = kzalloc(sizeof(*last), GFP_KERNEL); last = kzalloc(sizeof(*last), GFP_KERNEL_ACCOUNT);
if (!last) if (!last)
return -ENOMEM; return -ENOMEM;
......
...@@ -90,7 +90,7 @@ static int nft_limit_init(struct nft_limit_priv *priv, ...@@ -90,7 +90,7 @@ static int nft_limit_init(struct nft_limit_priv *priv,
priv->rate); priv->rate);
} }
priv->limit = kmalloc(sizeof(*priv->limit), GFP_KERNEL); priv->limit = kmalloc(sizeof(*priv->limit), GFP_KERNEL_ACCOUNT);
if (!priv->limit) if (!priv->limit)
return -ENOMEM; return -ENOMEM;
......
...@@ -90,7 +90,7 @@ static int nft_quota_do_init(const struct nlattr * const tb[], ...@@ -90,7 +90,7 @@ static int nft_quota_do_init(const struct nlattr * const tb[],
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
priv->consumed = kmalloc(sizeof(*priv->consumed), GFP_KERNEL); priv->consumed = kmalloc(sizeof(*priv->consumed), GFP_KERNEL_ACCOUNT);
if (!priv->consumed) if (!priv->consumed)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment