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] [day] [month] [year] [list]
Message-ID: <20190523152314.GP28207@linux.ibm.com>
Date:   Thu, 23 May 2019 08:23:14 -0700
From:   "Paul E. McKenney" <paulmck@...ux.ibm.com>
To:     Mark Rutland <mark.rutland@....com>
Cc:     Andrea Parri <andrea.parri@...rulasolutions.com>,
        linux-kernel@...r.kernel.org,
        Josh Triplett <josh@...htriplett.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Joel Fernandes <joel@...lfernandes.org>, rcu@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Will Deacon <will.deacon@....com>
Subject: Re: [RFC PATCH] rcu: Make 'rcu_assign_pointer(p, v)' of type
 'typeof(p)'

On Thu, May 23, 2019 at 03:19:19PM +0100, Mark Rutland wrote:
> On Thu, May 23, 2019 at 06:50:13AM -0700, Paul E. McKenney wrote:
> > On Thu, May 23, 2019 at 03:32:20PM +0200, Andrea Parri wrote:
> > > The expression
> > > 
> > >   rcu_assign_pointer(p, typeof(p) v)
> > > 
> > > is reported to be of type 'typeof(p)' in the documentation (c.f., e.g.,
> > > Documentation/RCU/whatisRCU.txt) but this is not the case: for example,
> > > the following snippet
> > > 
> > >   int **y;
> > >   int *x;
> > >   int *r0;
> > > 
> > >   ...
> > > 
> > >   r0 = rcu_assign_pointer(*y, x);
> > > 
> > > can currently result in the compiler warning
> > > 
> > >   warning: assignment to ‘int *’ from ‘uintptr_t’ {aka ‘long unsigned int’} makes pointer from integer without a cast [-Wint-conversion]
> > > 
> > > Cast the uintptr_t value to a typeof(p) value.
> > > 
> > > Signed-off-by: Andrea Parri <andrea.parri@...rulasolutions.com>
> > > Cc: "Paul E. McKenney" <paulmck@...ux.ibm.com>
> > > Cc: Josh Triplett <josh@...htriplett.org>
> > > Cc: Steven Rostedt <rostedt@...dmis.org>
> > > Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
> > > Cc: Lai Jiangshan <jiangshanlai@...il.com>
> > > Cc: Joel Fernandes <joel@...lfernandes.org>
> > > Cc: rcu@...r.kernel.org
> > > Cc: Peter Zijlstra <peterz@...radead.org>
> > > Cc: Will Deacon <will.deacon@....com>
> > > Cc: Mark Rutland <mark.rutland@....com>
> > > ---
> > > NOTE:
> > > 
> > > TBH, I'm not sure this is 'the right patch' (hence the RFC...): in
> > > fact, I'm currently missing the motivations for allowing assignments
> > > such as the "r0 = ..." assignment above in generic code.  (BTW, it's
> > > not currently possible to use such assignments in litmus tests...)
> > 
> > Given that a quick (and perhaps error-prone) search of the uses of
> > rcu_assign_pointer() in v5.1 didn't find a single use of the return
> > value, let's please instead change the documentation and implementation
> > to eliminate the return value.
> 
> FWIW, I completely agree, and for similar reasons I'd say we should do
> the same to WRITE_ONCE(), where this 'cool feature' has been inherited
> from.
> 
> For WRITE_ONCE() there's at least one user that needs to be cleaned up
> first (relying on non-portable implementation detaisl of atomic*_set()),
> but I suspect rcu_assign_pointer() isn't used as much as a building
> block for low-level macros.

Agreed, for rcu_assign_pointer(), there were only a couple, and I checked
them as well.  Doesn't mean I didn't miss something, of course!

I also got an offlist report of rcu_assign_pointer() not working for
pointers to incomplete structures.  Which can be fixed by removing
the RCU_INITIALIZER() from the second argument of the smp_store_release().
Which destroys sparse's ability to check for __rcu.

One approach would be to have a separate rcu_assign_pointer_opaque()
for opaque pointers, and people would just ignore the sparse warnings.

Other suggestions?

							Thanx, Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ