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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9580167080271af15ef6f1f9d9baa586539bc34e.camel@kernel.org>
Date: Fri, 25 Apr 2025 08:40:09 -0400
From: Jeff Layton <jlayton@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, Andrew Morton <akpm@...ux-foundation.org>,
  "David S. Miller" <davem@...emloft.net>, Paolo Abeni <pabeni@...hat.com>,
 Simon Horman <horms@...nel.org>, Kuniyuki Iwashima <kuniyu@...zon.com>,
 Qasim Ijaz <qasdev00@...il.com>, Nathan Chancellor <nathan@...nel.org>, 
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH v4 7/7] net: register debugfs file for net_device refcnt
 tracker

On Thu, 2025-04-24 at 16:07 -0700, Eric Dumazet wrote:
> On Thu, Apr 24, 2025 at 3:52 PM Jakub Kicinski <kuba@...nel.org> wrote:
> 
> > But with all that said, I guess you still want the "meaningful" ID for
> > the netns, and that one is in fact stable :S
> 
> We could add a stable id for net devices, and use it for this purpose
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0321fd952f70887735ac789d72f72948a3879832..339d09167eaf7f58fc877fa470c94175237ce534
> 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2544,6 +2544,8 @@ struct net_device {
> 
>         struct hwtstamp_provider __rcu  *hwprov;
> 
> +       u64                     permanent_id;
> +
>         u8                      priv[] ____cacheline_aligned
>                                        __counted_by(priv_len);
>  } ____cacheline_aligned;
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d1a8cad0c99c47996e8bda44bf220266a5e51102..9d2d45e0246fab99ad3e7523885224bd114fa686
> 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -10954,6 +10954,9 @@ int register_netdevice(struct net_device *dev)
>  {
>         int ret;
>         struct net *net = dev_net(dev);
> +       static atomic64_t permanent_id;
> +
> +       dev->permanent_id = atomic64_inc_return(&permanent_id);
> 
>         BUILD_BUG_ON(sizeof(netdev_features_t) * BITS_PER_BYTE <
>                      NETDEV_FEATURE_COUNT);

That would give us uniqueness, but the name doesn't mean anything and
it wouldn't be trivial to track down which ref_tracker/netdev-* file
refers to which device.

If we're going to go that route, we're probably better off just
embedding the address in the name using a "netdev@%px" format.
-- 
Jeff Layton <jlayton@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ