Skip to contentSkip to conversation

net: correct check in dev_addr_del()

PATCH In review Jiri Pirko 4 participants 9 messages Nov 14, 2012 – Jan 12, 2013

Subsystems (2)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 net: correct check in dev_addr_del()

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

---
 net/core/dev_addr_lists.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dev_addr_lists.c +2 -1
index 87cc17d..b079c7b 100644
@@ -319,7 +319,8 @@ int dev_addr_del(struct net_device *dev, const unsigned char *addr,
 	 */
 	ha = list_first_entry(&dev->dev_addrs.list,
 			      struct netdev_hw_addr, list);
-	if (ha->addr == dev->dev_addr && ha->refcount == 1)
+	if (!memcmp(ha->addr, addr, dev->addr_len) &&
+	    ha->type == addr_type && ha->refcount == 1)
 		return -ENOENT;
 
 	err = __hw_addr_del(&dev->dev_addrs, addr, dev->addr_len,
Signature · 1 line
1.8.0
#1 lore raw
Quoted 5 lines · Jiri Pirko

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

---

Please add in the changelog which commit added the bug, to ease stable teams work.

Thanks

author
#2 lore raw
Quoted 9 lines · Wed, Nov 14, 2012 at 03:18:35PM CET, [email protected] wrote:
Quoted 5 lines · Jiri Pirko

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

---

Please add in the changelog which commit added the bug, to ease stable teams work.

bug introduced by:

commit a748ee2426817a95b1f03012d8f339c45c722ae1

Author: Jiri Pirko <[email protected]>
Date:   Thu Apr 1 21:22:09 2010 +0000

net: move address list functions to a separate file

Quoted 4 lines

Thanks

#3 lore raw
Quoted 11 lines · Jiri Pirko
Quoted 9 lines · Wed, Nov 14, 2012 at 03:18:35PM CET, [email protected] wrote:
Quoted 5 lines · Jiri Pirko

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

---

Please add in the changelog which commit added the bug, to ease stable teams work.

Quoted 7 lines

bug introduced by:

commit a748ee2426817a95b1f03012d8f339c45c722ae1

Author: Jiri Pirko <[email protected]>
Date:   Thu Apr 1 21:22:09 2010 +0000

net: move address list functions to a separate file

Good, the usual way is then to add in the changelog :

Bug added in commit a748ee242681
(net: move address list functions to a separate file)

(No need to give the author/date, and we can shorten the SHA1 to 10 or 12 digits)

Thanks

author
#4 lore raw
Quoted 20 lines · Wed, Nov 14, 2012 at 03:38:59PM CET, [email protected] wrote:
Quoted 11 lines · Jiri Pirko
Quoted 9 lines · Wed, Nov 14, 2012 at 03:18:35PM CET, [email protected] wrote:
Quoted 5 lines · Jiri Pirko

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

---

Please add in the changelog which commit added the bug, to ease stable teams work.

Quoted 7 lines

bug introduced by:

commit a748ee2426817a95b1f03012d8f339c45c722ae1

Author: Jiri Pirko <[email protected]>
Date:   Thu Apr 1 21:22:09 2010 +0000

net: move address list functions to a separate file

Quoted 8 lines

Good, the usual way is then to add in the changelog :

Bug added in commit a748ee242681
(net: move address list functions to a separate file)

(No need to give the author/date, and we can shorten the SHA1 to 10 or 12 digits)

Mind noted. Thanks Eric.

Quoted 4 lines

Thanks

maintainer
#6 lore raw
In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>
Date: Wed, 14 Nov 2012 13:51:04 +0100

Quoted 4 lines

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

I'm pretty sure this is very intentional.

It's trying to prevent deletion of the implicit dev->dev_addr entry. But it will allow decementing the reference count to 1, but no further.

I'm not applying this.

author
#7 lore raw
Quoted 8 lines · Thu, Nov 15, 2012 at 03:52:54AM CET, [email protected] wrote:

From: Jiri Pirko <[email protected]>
Date: Wed, 14 Nov 2012 13:51:04 +0100

Quoted 4 lines

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

Quoted 7 lines

I'm pretty sure this is very intentional.

It's trying to prevent deletion of the implicit dev->dev_addr entry. But it will allow decementing the reference count to 1, but no further.

I'm not applying this.

Please look at dev_addr_init(), line 266:
dev->dev_addr = ha->addr;

and that is never changed.
Therefore check (ha->addr == dev->dev_addr) in dev_addr_del() is always true and has no meaning.

dev_addr_del() should check if the address passed in "const unsigned char *addr" function arg is the same as in ha->addr (dev->dev_addr) and prevent to remove it in that case. And that is what this patch does.

maintainer
#8 lore raw

From: Jiri Pirko <[email protected]>
Date: Thu, 15 Nov 2012 11:12:38 +0100

Quoted 20 lines
Quoted 8 lines · Thu, Nov 15, 2012 at 03:52:54AM CET, [email protected] wrote:

From: Jiri Pirko <[email protected]>
Date: Wed, 14 Nov 2012 13:51:04 +0100

Quoted 4 lines

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init() sets this. Correct the check to behave properly on addr removal.

Quoted 7 lines

I'm pretty sure this is very intentional.

It's trying to prevent deletion of the implicit dev->dev_addr entry. But it will allow decementing the reference count to 1, but no further.

I'm not applying this.

Please look at dev_addr_init(), line 266:
dev->dev_addr = ha->addr;

Quoted 7 lines

and that is never changed.
Therefore check (ha->addr == dev->dev_addr) in dev_addr_del() is always true and has no meaning.

dev_addr_del() should check if the address passed in "const unsigned char *addr" function arg is the same as in ha->addr (dev->dev_addr) and prevent to remove it in that case. And that is what this patch does.

Thanks for explaining. I misread the code and thought that 'ha' was already the object looked up using 'addr' as the key.

Applied and queued up for -stable, thanks.

#5 lore raw
In reply to Eric Dumazet
Quoted 9 lines · Eric Dumazet
Quoted 8 lines

bug introduced by:

commit a748ee2426817a95b1f03012d8f339c45c722ae1

Author: Jiri Pirko <[email protected]>
Date:   Thu Apr 1 21:22:09 2010 +0000

net: move address list functions to a separate file

Quoted 7 lines

Good, the usual way is then to add in the changelog :

Bug added in commit a748ee242681
(net: move address list functions to a separate file)

(No need to give the author/date, and we can shorten the SHA1 to 10 or 12 digits)

A shortened hash value is however not truly future-proof. I recommend using git describe or git describe --contains, as that is unambiguous into the future and shows a related version. In case of a748ee, that would be v2.6.35-rc1~473^2~602, which immediately tells us that the bug has been in tarballs since 2.6.35-rc1.