diff mbox series

[net-next] net: prestera: acl: fix 'client_map' buff overflow

Message ID 1645187351-8489-1-git-send-email-volodymyr.mytnyk@plvision.eu (mailing list archive)
State Accepted
Commit 48c77bdf729a91fa7f65765d3f60f01e0ac320c5
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: prestera: acl: fix 'client_map' buff overflow | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Volodymyr Mytnyk Feb. 18, 2022, 12:29 p.m. UTC
From: Volodymyr Mytnyk <vmytnyk@marvell.com>

smatch warnings:
drivers/net/ethernet/marvell/prestera/prestera_acl.c:103
prestera_acl_chain_to_client() error: buffer overflow
'client_map' 3 <= 3

	prestera_acl_chain_to_client(u32 chain_index, ...)
        ...
	u32 client_map[] = {
		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_0,
		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_1,
		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_2
	};
	if (chain_index > ARRAY_SIZE(client_map))
	...

Fixes: fa5d824ce5dd ("net: prestera: acl: add multi-chain support offload")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
---
 drivers/net/ethernet/marvell/prestera/prestera_acl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 19, 2022, 7 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 18 Feb 2022 14:29:11 +0200 you wrote:
> From: Volodymyr Mytnyk <vmytnyk@marvell.com>
> 
> smatch warnings:
> drivers/net/ethernet/marvell/prestera/prestera_acl.c:103
> prestera_acl_chain_to_client() error: buffer overflow
> 'client_map' 3 <= 3
> 
> [...]

Here is the summary with links:
  - [net-next] net: prestera: acl: fix 'client_map' buff overflow
    https://git.kernel.org/netdev/net-next/c/48c77bdf729a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_acl.c b/drivers/net/ethernet/marvell/prestera/prestera_acl.c
index 06303e31b32a..e4af8a503277 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_acl.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_acl.c
@@ -97,7 +97,7 @@  int prestera_acl_chain_to_client(u32 chain_index, u32 *client)
 		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_2
 	};
 
-	if (chain_index > ARRAY_SIZE(client_map))
+	if (chain_index >= ARRAY_SIZE(client_map))
 		return -EINVAL;
 
 	*client = client_map[chain_index];