[PATCH net] net: dsa: b53: fix an off by one in checking "vlan->vid"

Subsystems: broadcom b53/sf2 ethernet switch driver, networking drivers, networking [dsa], the rest

STALE2032d

3 messages, 3 authors, 2021-01-20 · open the first message on its own page

[PATCH net] net: dsa: b53: fix an off by one in checking "vlan->vid"

From: Dan Carpenter <hidden>
Date: 2021-01-19 18:27:18

The > comparison should be >= to prevent accessing one element beyond
the end of the dev->vlans[] array in the caller function, b53_vlan_add().
The "dev->vlans" array is allocated in the b53_switch_init() function
and it has "dev->num_vlans" elements.

Fixes: a2482d2ce349 ("net: dsa: b53: Plug in VLAN support")
Signed-off-by: Dan Carpenter <redacted>
---
 drivers/net/dsa/b53/b53_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 288b5a5c3e0d..95c7fa171e35 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1404,7 +1404,7 @@ int b53_vlan_prepare(struct dsa_switch *ds, int port,
 	    !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED))
 		return -EINVAL;
 
-	if (vlan->vid_end > dev->num_vlans)
+	if (vlan->vid_end >= dev->num_vlans)
 		return -ERANGE;
 
 	b53_enable_vlan(dev, true, ds->vlan_filtering);
-- 
2.29.2

Re: [PATCH net] net: dsa: b53: fix an off by one in checking "vlan->vid"

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2021-01-19 18:28:51


On 1/19/2021 6:48 AM, Dan Carpenter wrote:
The > comparison should be >= to prevent accessing one element beyond
the end of the dev->vlans[] array in the caller function, b53_vlan_add().
The "dev->vlans" array is allocated in the b53_switch_init() function
and it has "dev->num_vlans" elements.

Fixes: a2482d2ce349 ("net: dsa: b53: Plug in VLAN support")
Signed-off-by: Dan Carpenter <redacted>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

Re: [PATCH net] net: dsa: b53: fix an off by one in checking "vlan->vid"

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-01-20 03:38:02

On Tue, 19 Jan 2021 09:14:03 -0800 Florian Fainelli wrote:
On 1/19/2021 6:48 AM, Dan Carpenter wrote:
quoted
The > comparison should be >= to prevent accessing one element beyond
the end of the dev->vlans[] array in the caller function, b53_vlan_add().
The "dev->vlans" array is allocated in the b53_switch_init() function
and it has "dev->num_vlans" elements.

Fixes: a2482d2ce349 ("net: dsa: b53: Plug in VLAN support")
Signed-off-by: Dan Carpenter <redacted>  
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Applied, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help