]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net: systemport: fix index check to avoid an array out of bounds access
authorColin Ian King <colin.king@canonical.com>
Thu, 12 Mar 2020 15:04:30 +0000 (15:04 +0000)
committerPaolo Pisati <paolo.pisati@canonical.com>
Wed, 18 Mar 2020 10:23:17 +0000 (11:23 +0100)
BugLink: https://bugs.launchpad.net/bugs/1867903
[ Upstream commit c0368595c1639947839c0db8294ee96aca0b3b86 ]

Currently the bounds check on index is off by one and can lead to
an out of bounds access on array priv->filters_loc when index is
RXCHK_BRCM_TAG_MAX.

Fixes: bb9051a2b230 ("net: systemport: Add support for WAKE_FILTER")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/net/ethernet/broadcom/bcmsysport.c

index 4a27577e137bc7d5834b48c5a58112bc0e7414a4..ad86a186ddc5ff4922f4d3a3e70779e0793a7f34 100644 (file)
@@ -2135,7 +2135,7 @@ static int bcm_sysport_rule_set(struct bcm_sysport_priv *priv,
                return -ENOSPC;
 
        index = find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX);
-       if (index > RXCHK_BRCM_TAG_MAX)
+       if (index >= RXCHK_BRCM_TAG_MAX)
                return -ENOSPC;
 
        /* Location is the classification ID, and index is the position