2016-07-11 15:54:59

by Colin King

[permalink] [raw]
Subject: [PATCH][V2] nfp: check idx is -ENOSPC before using it is an index

From: Colin Ian King <[email protected]>

idx can be returned as -ENOSPC, so we should check for this first
before using it as an index into nn->vxlan_usecnt[] to avoid an
out of bounds array offset read.

Signed-off-by: Colin Ian King <[email protected]>
---
drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 1e74b91..88678c1 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2578,7 +2578,7 @@ static void nfp_net_del_vxlan_port(struct net_device *netdev,
return;

idx = nfp_net_find_vxlan_idx(nn, ti->port);
- if (!nn->vxlan_usecnt[idx] || idx == -ENOSPC)
+ if (idx == -ENOSPC || !nn->vxlan_usecnt[idx])
return;

if (!--nn->vxlan_usecnt[idx])
--
2.8.1



2016-07-11 20:52:20

by David Miller

[permalink] [raw]
Subject: Re: [PATCH][V2] nfp: check idx is -ENOSPC before using it is an index

From: Colin King <[email protected]>
Date: Mon, 11 Jul 2016 16:54:20 +0100

> From: Colin Ian King <[email protected]>
>
> idx can be returned as -ENOSPC, so we should check for this first
> before using it as an index into nn->vxlan_usecnt[] to avoid an
> out of bounds array offset read.
>
> Signed-off-by: Colin Ian King <[email protected]>

Applied to net-next.

2016-07-11 15:59:49

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [oss-drivers] [PATCH][V2] nfp: check idx is -ENOSPC before using it is an index

On Mon, 11 Jul 2016 16:54:20 +0100, Colin King wrote:
> From: Colin Ian King <[email protected]>
>
> idx can be returned as -ENOSPC, so we should check for this first
> before using it as an index into nn->vxlan_usecnt[] to avoid an
> out of bounds array offset read.
>
> Signed-off-by: Colin Ian King <[email protected]>

Acked-by: Jakub Kicinski <[email protected]>

Thanks!