Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: prestera: acl: fix 'client_map' buff overflow

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Volodymyr Mytnyk and committed by
David S. Miller
48c77bdf 173a272a

+1 -1
+1 -1
drivers/net/ethernet/marvell/prestera/prestera_acl.c
··· 97 97 PRESTERA_HW_COUNTER_CLIENT_LOOKUP_2 98 98 }; 99 99 100 - if (chain_index > ARRAY_SIZE(client_map)) 100 + if (chain_index >= ARRAY_SIZE(client_map)) 101 101 return -EINVAL; 102 102 103 103 *client = client_map[chain_index];