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]
Date:   Wed, 17 Nov 2021 10:35:45 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     Leon Romanovsky <leon@...nel.org>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, eric.dumazet@...il.com
Subject: Re: [RFC net-next 1/2] net: add netdev_refs debug

On Wed, 17 Nov 2021 20:24:17 +0200 Leon Romanovsky wrote:
> > +/* Store a raw, unprotected pointer */
> > +static inline void __netdev_ref_store(struct netdev_ref *ref,
> > +				      struct net_device *dev)
> > +{
> > +	ref->dev = dev;
> > +
> > +#ifdef CONFIG_DEBUG_OBJECTS_NETDEV_REFS
> > +	refcount_set(&ref->cnt, 0);  
> 
> This is very uncommon pattern. I would expect that first pointer access
> will start from 1, like all refcount_t users. If you still prefer to
> start from 0, i suggest you to use atomic_t. 

It's not really "starting from 0", it's more of a "setting the count
to invalid". It can't escape from this state with a simple inc.

> IMHO, much better will be to use kref for this type of reference counting.

I'm not really sure if the netdev_ref_{get,put}() part is necessary.

Main pattern I'm trying to replace is a pointer which is optionally 
holding a reference (0, 1 references). Rather than a pointer which 
is ref counted (1..n references).

IOW __netdev_ref_store() is much more likely to be used than
netdev_ref_get(), that's also why netdev_put() does not invalidate
the pointer itself.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ