[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1645187351-8489-1-git-send-email-volodymyr.mytnyk@plvision.eu>
Date: Fri, 18 Feb 2022 14:29:11 +0200
From: Volodymyr Mytnyk <volodymyr.mytnyk@...ision.eu>
To: netdev@...r.kernel.org
Cc: Taras Chornyi <taras.chornyi@...ision.eu>,
Mickey Rachamim <mickeyr@...vell.com>,
Serhiy Pshyk <serhiy.pshyk@...ision.eu>,
Volodymyr Mytnyk <vmytnyk@...vell.com>,
Taras Chornyi <tchornyi@...vell.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, linux-kernel@...r.kernel.org
Subject: [PATCH net-next] net: prestera: acl: fix 'client_map' buff overflow
From: Volodymyr Mytnyk <vmytnyk@...vell.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@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Volodymyr Mytnyk <vmytnyk@...vell.com>
---
drivers/net/ethernet/marvell/prestera/prestera_acl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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];
--
2.7.4
Powered by blists - more mailing lists