Re: [PATCH] Convert struct pid count to refcount_t

2019-04-04 Thread Joel Fernandes
On Thu, Apr 04, 2019 at 11:19:46AM -0700, Paul E. McKenney wrote: [snip] > > > > > Further, from the herd simulator output (below), according to the > > > > > "States", > > > > > r1==1 means P1() AFAICS would have already finished the the read and > > > > > set the > > > > > r1 register to 1.

Re: [PATCH] Convert struct pid count to refcount_t

2019-04-04 Thread Alan Stern
On Thu, 4 Apr 2019, Joel Fernandes wrote: > FWIW, thought to mention (feel free ignore the suggestion if its > meaningless): If there is any chance that the outcome can be better > outputted, like r1=X; x=1; Where X stands for the result of a data race, that > would be lovely. I don't know much

Re: [PATCH] Convert struct pid count to refcount_t

2019-04-04 Thread Paul E. McKenney
On Thu, Apr 04, 2019 at 02:08:42PM -0400, Joel Fernandes wrote: > Thanks a lot Paul and Allen, I replied below. > > On Thu, Apr 04, 2019 at 12:01:32PM -0400, Alan Stern wrote: > > On Thu, 4 Apr 2019, Paul E. McKenney wrote: > > > > > On Mon, Apr 01, 2019 at 05:11:39PM -0400, Joel Fernandes

Re: [PATCH] Convert struct pid count to refcount_t

2019-04-04 Thread Joel Fernandes
Thanks a lot Paul and Allen, I replied below. On Thu, Apr 04, 2019 at 12:01:32PM -0400, Alan Stern wrote: > On Thu, 4 Apr 2019, Paul E. McKenney wrote: > > > On Mon, Apr 01, 2019 at 05:11:39PM -0400, Joel Fernandes wrote: > > > > > > So I would have expected the following litmus to result in

Re: [PATCH] Convert struct pid count to refcount_t

2019-04-04 Thread Alan Stern
On Thu, 4 Apr 2019, Paul E. McKenney wrote: > On Mon, Apr 01, 2019 at 05:11:39PM -0400, Joel Fernandes wrote: > > > > So I would have expected the following litmus to result in Never, but it > > > > doesn't with Alan's patch: > > > > > > > > P0(int *x, int *y) > > > > { > > > > *x = 1;

Re: [PATCH] Convert struct pid count to refcount_t

2019-04-04 Thread Paul E. McKenney
On Mon, Apr 01, 2019 at 05:11:39PM -0400, Joel Fernandes wrote: > Thanks a lot Alan and Paul for the replies. I replied inline. > > On Sun, Mar 31, 2019 at 02:55:31PM -0700, Paul E. McKenney wrote: > > On Fri, Mar 29, 2019 at 10:36:39PM -0400, Joel Fernandes wrote: > > > On Thu, Mar 28, 2019 at

Re: [PATCH] Convert struct pid count to refcount_t

2019-04-01 Thread Joel Fernandes
Thanks a lot Alan and Paul for the replies. I replied inline. On Sun, Mar 31, 2019 at 02:55:31PM -0700, Paul E. McKenney wrote: > On Fri, Mar 29, 2019 at 10:36:39PM -0400, Joel Fernandes wrote: > > On Thu, Mar 28, 2019 at 10:37:07AM -0700, Paul E. McKenney wrote: > > > On Thu, Mar 28, 2019 at

RE: [PATCH] Convert struct pid count to refcount_t

2019-04-01 Thread David Laight
From: Alan Stern > Sent: 29 March 2019 19:45 ... > There is a big difference between WRITE_ONCE() and plain assignment. > Given "WRITE_ONCE(X, 2)", the compiler will emit a simple store > instruction. But given "X = 2", the compiler is allowed to emit > instructions equivalent to: > > if

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-31 Thread Paul E. McKenney
On Sat, Mar 30, 2019 at 11:16:01AM -0400, Alan Stern wrote: > On Fri, 29 Mar 2019, Joel Fernandes wrote: > > On Thu, Mar 28, 2019 at 10:37:07AM -0700, Paul E. McKenney wrote: > > > On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > > > > On 03/28, Jann Horn wrote: > > > > > > > > > >

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-31 Thread Paul E. McKenney
On Fri, Mar 29, 2019 at 10:36:39PM -0400, Joel Fernandes wrote: > On Thu, Mar 28, 2019 at 10:37:07AM -0700, Paul E. McKenney wrote: > > On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > > > On 03/28, Jann Horn wrote: > > > > > > > > Since we're just talking about RCU stuff now,

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-30 Thread Alan Stern
On Fri, 29 Mar 2019, Joel Fernandes wrote: > On Thu, Mar 28, 2019 at 10:37:07AM -0700, Paul E. McKenney wrote: > > On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > > > On 03/28, Jann Horn wrote: > > > > > > > > Since we're just talking about RCU stuff now, adding Paul McKenney to

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-29 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 10:37:07AM -0700, Paul E. McKenney wrote: > On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > > On 03/28, Jann Horn wrote: > > > > > > Since we're just talking about RCU stuff now, adding Paul McKenney to > > > the thread. > > > > Since you added Paul let me

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-29 Thread Alan Stern
On Fri, 29 Mar 2019, Oleg Nesterov wrote: > On 03/28, Paul E. McKenney wrote: > > > > On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > > > > > > Since you added Paul let me add more confusion to this thread ;) > > > > Woo-hoo!!! More confusion! Bring it on!!! ;-) > > OK,

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-29 Thread Oleg Nesterov
On 03/28, Joel Fernandes wrote: > > Also Oleg, why not just call refcount_dec_and_test like below? Of course we can, this is just optimization to avoid the atomic op if possible. Does this optimization really help? I have no idea ;) But as you can see, it surely helps to provoke the interesting

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-29 Thread Oleg Nesterov
On 03/28, Paul E. McKenney wrote: > > On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > > > > Since you added Paul let me add more confusion to this thread ;) > > Woo-hoo!!! More confusion! Bring it on!!! ;-) OK, thanks, you certainly managed to confused me much more than I

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 10:39:58AM -0400, Joel Fernandes wrote: > On Thu, Mar 28, 2019 at 03:26:19PM +0100, Oleg Nesterov wrote: > > On 03/27, Joel Fernandes wrote: > > > > > > Also, based on Kees comment, I think it appears to me that get_pid and > > > put_pid can race in this way in the original

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 04:00:52PM -0400, Joel Fernandes wrote: > On Thu, Mar 28, 2019 at 04:17:50PM +0100, Jann Horn wrote: > > Since we're just talking about RCU stuff now, adding Paul McKenney to > > the thread. > > > > On Thu, Mar 28, 2019 at 3:37 PM Joel Fernandes > > wrote: > > > On Thu,

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 04:17:50PM +0100, Jann Horn wrote: > Since we're just talking about RCU stuff now, adding Paul McKenney to > the thread. > > On Thu, Mar 28, 2019 at 3:37 PM Joel Fernandes wrote: > > On Thu, Mar 28, 2019 at 03:57:44AM +0100, Jann Horn wrote: > > > On Thu, Mar 28, 2019 at

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Paul E. McKenney
On Thu, Mar 28, 2019 at 05:26:42PM +0100, Oleg Nesterov wrote: > On 03/28, Jann Horn wrote: > > > > Since we're just talking about RCU stuff now, adding Paul McKenney to > > the thread. > > Since you added Paul let me add more confusion to this thread ;) Woo-hoo!!! More confusion! Bring it

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Kees Cook
On Thu, Mar 28, 2019 at 7:37 AM Joel Fernandes wrote: > Kees can you describe more the race you had in mind? I just didn't see any barriers, so it seemed racey to me. > Also note to the on looker, the original patch I sent is not wrong, that > still applies and is correct. We are just

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Oleg Nesterov
On 03/28, Jann Horn wrote: > > Since we're just talking about RCU stuff now, adding Paul McKenney to > the thread. Since you added Paul let me add more confusion to this thread ;) There were some concerns about the lack of barriers in put_pid(), but I can't find that old discussion and I forgot

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Jann Horn
Since we're just talking about RCU stuff now, adding Paul McKenney to the thread. On Thu, Mar 28, 2019 at 3:37 PM Joel Fernandes wrote: > On Thu, Mar 28, 2019 at 03:57:44AM +0100, Jann Horn wrote: > > On Thu, Mar 28, 2019 at 3:34 AM Joel Fernandes > > wrote: > > > On Thu, Mar 28, 2019 at

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 03:26:19PM +0100, Oleg Nesterov wrote: > On 03/27, Joel Fernandes wrote: > > > > Also, based on Kees comment, I think it appears to me that get_pid and > > put_pid can race in this way in the original code right? > > > > get_pid put_pid > > > >

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 03:57:44AM +0100, Jann Horn wrote: > On Thu, Mar 28, 2019 at 3:34 AM Joel Fernandes wrote: > > On Thu, Mar 28, 2019 at 01:59:45AM +0100, Jann Horn wrote: > > > On Thu, Mar 28, 2019 at 1:06 AM Kees Cook wrote: > > > > On Wed, Mar 27, 2019 at 7:53 AM Joel Fernandes (Google)

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-28 Thread Oleg Nesterov
On 03/27, Joel Fernandes wrote: > > Also, based on Kees comment, I think it appears to me that get_pid and > put_pid can race in this way in the original code right? > > get_pid put_pid > > atomic_dec_and_test returns 1 > atomic_inc >

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-27 Thread Jann Horn
On Thu, Mar 28, 2019 at 3:34 AM Joel Fernandes wrote: > On Thu, Mar 28, 2019 at 01:59:45AM +0100, Jann Horn wrote: > > On Thu, Mar 28, 2019 at 1:06 AM Kees Cook wrote: > > > On Wed, Mar 27, 2019 at 7:53 AM Joel Fernandes (Google) > > > wrote: > > > > > > > > struct pid's count is an atomic_t

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-27 Thread Joel Fernandes
On Thu, Mar 28, 2019 at 01:59:45AM +0100, Jann Horn wrote: > On Thu, Mar 28, 2019 at 1:06 AM Kees Cook wrote: > > On Wed, Mar 27, 2019 at 7:53 AM Joel Fernandes (Google) > > wrote: > > > > > > struct pid's count is an atomic_t field used as a refcount. Use > > > refcount_t for it which is

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-27 Thread Jann Horn
On Thu, Mar 28, 2019 at 1:06 AM Kees Cook wrote: > On Wed, Mar 27, 2019 at 7:53 AM Joel Fernandes (Google) > wrote: > > > > struct pid's count is an atomic_t field used as a refcount. Use > > refcount_t for it which is basically atomic_t but does additional > > checking to prevent use-after-free

Re: [PATCH] Convert struct pid count to refcount_t

2019-03-27 Thread Kees Cook
On Wed, Mar 27, 2019 at 7:53 AM Joel Fernandes (Google) wrote: > > struct pid's count is an atomic_t field used as a refcount. Use > refcount_t for it which is basically atomic_t but does additional > checking to prevent use-after-free bugs. No change in behavior if > CONFIG_REFCOUNT_FULL=n. > >

[PATCH] Convert struct pid count to refcount_t

2019-03-27 Thread Joel Fernandes (Google)
struct pid's count is an atomic_t field used as a refcount. Use refcount_t for it which is basically atomic_t but does additional checking to prevent use-after-free bugs. No change in behavior if CONFIG_REFCOUNT_FULL=n. Cc: keesc...@chromium.org Cc: kernel-t...@android.com Cc: