Message ID | b3b47b25-01fc-4d9f-a6c3-e037ad4d71d7@moroto.mountain (mailing list archive) |
---|---|
State | Accepted |
Commit | 48d17c517a7af933346bd095e8ccc52b8477b274 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: bcmasp: Prevent array undereflow in bcmasp_netfilt_get_init() | expand |
On 8/7/2023 6:01 AM, Dan Carpenter wrote: > The "loc" value comes from the user and it can be negative leading to an > an array underflow when we check "priv->net_filters[loc].claimed". Fix > this by changing the type to u32. > > Fixes: c5d511c49587 ("net: bcmasp: Add support for wake on net filters") > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
On 8/7/23 6:01 AM, Dan Carpenter wrote: > The "loc" value comes from the user and it can be negative leading to an > an array underflow when we check "priv->net_filters[loc].claimed". Fix > this by changing the type to u32. > > Fixes: c5d511c49587 ("net: bcmasp: Add support for wake on net filters") > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Justin Chen <justin.chen@broadcom.com> > --- > Recent code. Only needed on net-next. > > drivers/net/ethernet/broadcom/asp2/bcmasp.c | 2 +- > drivers/net/ethernet/broadcom/asp2/bcmasp.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c > index eb35ced1c8ba..d63d321f3e7b 100644 > --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c > +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c > @@ -640,7 +640,7 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf, > * If no more open filters return NULL > */ > struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, > - int loc, bool wake_filter, > + u32 loc, bool wake_filter, > bool init) > { > struct bcmasp_net_filter *nfilter = NULL; > diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.h b/drivers/net/ethernet/broadcom/asp2/bcmasp.h > index 6bfcaa7f95a8..5b512f7f5e94 100644 > --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.h > +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.h > @@ -566,7 +566,7 @@ void bcmasp_disable_all_filters(struct bcmasp_intf *intf); > void bcmasp_core_clock_set_intf(struct bcmasp_intf *intf, bool en); > > struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, > - int loc, bool wake_filter, > + u32 loc, bool wake_filter, > bool init); > > bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf,
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Mon, 7 Aug 2023 16:01:53 +0300 you wrote: > The "loc" value comes from the user and it can be negative leading to an > an array underflow when we check "priv->net_filters[loc].claimed". Fix > this by changing the type to u32. > > Fixes: c5d511c49587 ("net: bcmasp: Add support for wake on net filters") > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> > > [...] Here is the summary with links: - [net-next] net: bcmasp: Prevent array undereflow in bcmasp_netfilt_get_init() https://git.kernel.org/netdev/net-next/c/48d17c517a7a You are awesome, thank you!
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c index eb35ced1c8ba..d63d321f3e7b 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -640,7 +640,7 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf, * If no more open filters return NULL */ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, - int loc, bool wake_filter, + u32 loc, bool wake_filter, bool init) { struct bcmasp_net_filter *nfilter = NULL; diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.h b/drivers/net/ethernet/broadcom/asp2/bcmasp.h index 6bfcaa7f95a8..5b512f7f5e94 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.h +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.h @@ -566,7 +566,7 @@ void bcmasp_disable_all_filters(struct bcmasp_intf *intf); void bcmasp_core_clock_set_intf(struct bcmasp_intf *intf, bool en); struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, - int loc, bool wake_filter, + u32 loc, bool wake_filter, bool init); bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf,
The "loc" value comes from the user and it can be negative leading to an an array underflow when we check "priv->net_filters[loc].claimed". Fix this by changing the type to u32. Fixes: c5d511c49587 ("net: bcmasp: Add support for wake on net filters") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> --- Recent code. Only needed on net-next. drivers/net/ethernet/broadcom/asp2/bcmasp.c | 2 +- drivers/net/ethernet/broadcom/asp2/bcmasp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)