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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 15 Dec 2020 18:24:37 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     Wei Wang <weiwan@...gle.com>
Cc:     David Miller <davem@...emloft.net>,
        Linux Kernel Network Developers <netdev@...r.kernel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Hannes Frederic Sowa <hannes@...essinduktion.org>,
        Felix Fietkau <nbd@....name>,
        Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH net-next v5 2/3] net: implement threaded-able napi poll
 loop support

On Tue, 15 Dec 2020 18:15:06 -0800 Wei Wang wrote:
> On Tue, Dec 15, 2020 at 5:53 PM Jakub Kicinski <kuba@...nel.org> wrote:
> > On Tue, 15 Dec 2020 17:25:14 -0800 Wei Wang wrote:  
> > > +void napi_enable(struct napi_struct *n)
> > > +{
> > > +     bool locked = rtnl_is_locked();  
> >
> > Maybe you'll prove me wrong but I think this is never a correct
> > construct.  
> 
> Sorry, I don't get what you mean here.

You're checking if the mutex is locked, not if the caller is holding
the mutex.

> > > +     BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
> > > +     smp_mb__before_atomic();
> > > +     clear_bit(NAPI_STATE_SCHED, &n->state);
> > > +     clear_bit(NAPI_STATE_NPSVC, &n->state);
> > > +     if (!locked)
> > > +             rtnl_lock();  
> >
> > Why do we need the lock? Can't we assume the caller of napi_enable()
> > has the sole ownership of the napi instance? Surely clearing the other
> > flags would be pretty broken as well, so the napi must had been
> > disabled when this is called by the driver.
> >  
> 
> Hmm... OK. The reason I added this lock operation is that we have
> ASSERT_RTNL() check in napi_set_threaded(), because it is necessary
> from the net-sysfs path to grab rtnl lock when modifying the threaded
> mode. Maybe it is not needed here.

Fair point, the sysfs write path could try to change the setting while
the NIC is starting.

> And the reason I added a rtnl_is_locked() check is I found mlx driver
> already holds rtnl lock before calling napi_enable(). Not sure about
> other drivers though.

I'd think most drivers will only mess around with napi under rtnl_lock.

> > > +     WARN_ON(napi_set_threaded(n, n->dev->threaded));
> > > +     if (!locked)
> > > +             rtnl_unlock();
> > > +}
> > > +EXPORT_SYMBOL(napi_enable);  

Powered by blists - more mailing lists