]> git.baikalelectronics.ru Git - kernel.git/commit
net: atlantic: Avoid out-of-bounds indexing
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Fri, 8 Apr 2022 02:22:04 +0000 (10:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 12:38:56 +0000 (14:38 +0200)
commitd4b6adbd85e962250daadb2e975a300ee2a6dd02
tree07350ba1e23d51ae441ff73cc9f7a73206fae6d1
parentb2d47fda78973021f2f6ca0d2e30482f9aba8d96
net: atlantic: Avoid out-of-bounds indexing

[ Upstream commit e74754b96aa9e69280085ddce3b490853af33208 ]

UBSAN warnings are observed on atlantic driver:
[ 294.432996] UBSAN: array-index-out-of-bounds in /build/linux-Qow4fL/linux-5.15.0/drivers/net/ethernet/aquantia/atlantic/aq_nic.c:484:48
[ 294.433695] index 8 is out of range for type 'aq_vec_s *[8]'

The ring is dereferenced right before breaking out the loop, to prevent
that from happening, only use the index in the loop to fix the issue.

BugLink: https://bugs.launchpad.net/bugs/1958770
Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reviewed-by: Igor Russkikh <irusskikh@marvell.com>
Link: https://lore.kernel.org/r/20220408022204.16815-1-kai.heng.feng@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/aquantia/atlantic/aq_nic.c
drivers/net/ethernet/aquantia/atlantic/aq_vec.c