diff mbox series

[net,1/4] netfilter: nftables: fix incorrect increment of loop counter

Message ID 20201218120409.3659-2-pablo@netfilter.org (mailing list archive)
State Accepted
Commit 161b838e25c6f83495e27e3f546b893622d442bf
Delegated to: Netdev Maintainers
Headers show
Series [net,1/4] netfilter: nftables: fix incorrect increment of loop counter | expand

Checks

Context Check Description
netdev/cover_letter success Pull request
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Pablo Neira Ayuso Dec. 18, 2020, 12:04 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The intention of the err_expr cleanup path is to iterate over the
allocated expr_array objects and free them, starting from i - 1 and
working down to the start of the array. Currently the loop counter
is being incremented instead of decremented and also the index i is
being used instead of k, repeatedly destroying the same expr_array
element.  Fix this by decrementing k and using k as the index into
expr_array.

Addresses-Coverity: ("Infinite loop")
Fixes: 8cfd9b0f8515 ("netfilter: nftables: generalize set expressions support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 19, 2020, 2:20 a.m. UTC | #1
Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Fri, 18 Dec 2020 13:04:06 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The intention of the err_expr cleanup path is to iterate over the
> allocated expr_array objects and free them, starting from i - 1 and
> working down to the start of the array. Currently the loop counter
> is being incremented instead of decremented and also the index i is
> being used instead of k, repeatedly destroying the same expr_array
> element.  Fix this by decrementing k and using k as the index into
> expr_array.
> 
> [...]

Here is the summary with links:
  - [net,1/4] netfilter: nftables: fix incorrect increment of loop counter
    https://git.kernel.org/netdev/net/c/161b838e25c6
  - [net,2/4] netfilter: x_tables: Update remaining dereference to RCU
    https://git.kernel.org/netdev/net/c/443d6e86f821
  - [net,3/4] netfilter: ipset: fixes possible oops in mtype_resize
    https://git.kernel.org/netdev/net/c/2b33d6ffa9e3
  - [net,4/4] netfilter: ipset: fix shift-out-of-bounds in htable_bits()
    https://git.kernel.org/netdev/net/c/5c8193f568ae

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 8d5aa0ac45f4..4186b1e52d58 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -5254,8 +5254,8 @@  static int nft_set_elem_expr_clone(const struct nft_ctx *ctx,
 	return 0;
 
 err_expr:
-	for (k = i - 1; k >= 0; k++)
-		nft_expr_destroy(ctx, expr_array[i]);
+	for (k = i - 1; k >= 0; k--)
+		nft_expr_destroy(ctx, expr_array[k]);
 
 	return -ENOMEM;
 }