Skip to contentSkip to conversation

Regression with 5dcd8400884c ("macsec: missing dev_put() on error in macsec_newlink()")

PATCH Applied Laura Abbott 4 participants 4 messages Apr 14, 2018 – Apr 16, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

Fedora got a bug report of a regression when trying to remove the the macsec module (https://bugzilla.redhat.com/show_bug.cgi?id=1566410).
I did a bisect and found

commit 5dcd8400884cc4a043a6d4617e042489e5d566a9

Author: Dan Carpenter <[email protected]>
Date:   Wed Mar 21 11:09:01 2018 +0300

macsec: missing dev_put() on error in macsec_newlink()

We moved the dev_hold(real_dev); call earlier in the function but forgot to update the error paths.

Fixes 0759e552bce7 ("macsec: fix negative refcnt on parent link")

The script I used for testing based on the reporter is attached. It looks like modprobe is stuck in the D state. Any idea?

Thanks,
Laura

maintainer
#1 lore raw

Hello Laura,

Quoted 13 lines · Laura Abbott

Hi,

Fedora got a bug report of a regression when trying to remove the the macsec module (https://bugzilla.redhat.com/show_bug.cgi?id=1566410).
I did a bisect and found

commit 5dcd8400884cc4a043a6d4617e042489e5d566a9

Author: Dan Carpenter <[email protected]>
Date:   Wed Mar 21 11:09:01 2018 +0300

macsec: missing dev_put() on error in macsec_newlink()
We moved the dev_hold(real_dev); call earlier in the function but forgot to update the error paths.

Quoted 6 lines
Fixes 0759e552bce7 ("macsec: fix negative refcnt on parent link")

The script I used for testing based on the reporter is attached. It looks like modprobe is stuck in the D state. Any idea?

I don't think that reference was actually leaked. It gets released in macsec_free_netdev() when the device is deleted.

modprobe getting stuck is just a side-effect of the refcount going negative on the parent device, since removing the module needs to take the lock that is held by device deletion.

I'll send a revert tomorrow.

Thanks for the report,

Signature · 1 line
Sabrina
#2 lore raw

PATCH 1/1 Revert "macsec: missing dev_put() on error in macsec_newlink()"

This patch is just wrong, sorry. I was trying to fix a static checker warning and misread the code. The reference taken in macsec_newlink() is released in macsec_free_netdev() when the netdevice is destroyed.

This reverts commit 5dcd8400884cc4a043a6d4617e042489e5d566a9.

Fixes 5dcd8400884c ("macsec: missing dev_put() on error in macsec_newlink()")

---
I sent this earlier but I messed up the CC list. I've updated the commit message as well.

 drivers/net/macsec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/macsec.c +2 -3
index 9cbb0c8a896a..7de88b33d5b9 100644
@@ -3277,7 +3277,7 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 
 	err = netdev_upper_dev_link(real_dev, dev, extack);
 	if (err < 0)
-		goto put_dev;
+		goto unregister;
 
 	/* need to be already registered so that ->init has run and
 	 * the MAC addr is set
@@ -3316,8 +3316,7 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 	macsec_del_dev(macsec);
 unlink:
 	netdev_upper_dev_unlink(real_dev, dev);
-put_dev:
-	dev_put(real_dev);
+unregister:
 	unregister_netdevice(dev);
 	return err;
 }
Signature · 1 line
2.16.2
maintainer Applied
#3 lore raw

Re: [PATCH net] Revert "macsec: missing dev_put() on error in macsec_newlink()"

From: Dan Carpenter <[email protected]>
Date: Mon, 16 Apr 2018 13:17:50 +0300

Quoted 6 lines

This patch is just wrong, sorry. I was trying to fix a static checker warning and misread the code. The reference taken in macsec_newlink() is released in macsec_free_netdev() when the netdevice is destroyed.

This reverts commit 5dcd8400884cc4a043a6d4617e042489e5d566a9.

Quoted 7 lines
Fixes 5dcd8400884c ("macsec: missing dev_put() on error in macsec_newlink()")

---
I sent this earlier but I messed up the CC list. I've updated the commit message as well.

Applied, thanks Dan.