lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <01100196d68da413-7c61137a-cfaf-4b23-9f91-9ca7064e4d42-000000@eu-north-1.amazonses.com>
Date: Fri, 16 May 2025 00:45:28 +0000
From: Ozgur Kara <ozgur@...sey.org>
To: "David S. Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>, 
	netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] net: devres: fix SET_NETDEV_DEV to devm_alloc_etherdev_mqs

From: Ozgur Karatas <ozgur@...sey.org>

Hello,
I read netdevice.h file and here when netdevice is allocated with
devm_alloc_etherdev_mqs() but this device is not set with
SET_NETDEV_DEV() and i think devm_register_netdev() is probably
crashing during device removal.

I guess ensuring ndev->dev.parent get devres_add(ndev->dev.parent, dr)
is loaded correctly and unregister_netdev() or free_netdev() will not
break anymore.

So if SET_NETDEV_DEV() is not present I guess ndev->dev.parent is a
null argument and devm_register_netdev() may bind resources to null
instead of dev.

This can be fixed by explicitly calling SET_NETDEV_DEV() immediately
after allocation.

Regards

Reported-by: Ozgur Karatas <ozgur@...sey.org>
---
 net/devres.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/devres.c b/net/devres.c
index 5ccf6ca311dc..a9ff607b916f 100644
--- a/net/devres.c
+++ b/net/devres.c
@@ -33,6 +33,7 @@ struct net_device *devm_alloc_etherdev_mqs(struct
device *dev, int sizeof_priv,
                return NULL;
        }

+       SET_NETDEV_DEV(dr->ndev, dev);
        devres_add(dev, dr);

        return dr->ndev;
--
2.39.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ