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, 9 Jun 2010 08:39:00 -0700 (PDT)
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Ingo Molnar <mingo@...e.hu>
cc:	Salman <sqazi@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	peterz@...radead.org, akpm@...x-foundation.org,
	linux-kernel@...r.kernel.org, tytso@...gle.com,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] Fix a race in pid generation that causes pids to be
 reused immediately.



On Wed, 9 Jun 2010, Ingo Molnar wrote:

> 
> * Salman <sqazi@...gle.com> wrote:
> > 
> > A program that repeatedly forks and waits is susceptible to having the
> > same pid repeated, especially when it competes with another instance of the
> > same program.  This is really bad for bash implementation.  Furthermore, many shell
> > scripts assume that pid numbers will not be used for some length of time.
> > 
> > Thanks to Ted Tso for the key ideas of this implementation.
> 
> Looks rather interesting. (Cleanliness-wise i'd suggest to split out the while 
> loop into a helper function.)

I have to say that usually I can look at a patch and see what it does.

This time I had absolutely no clue.

There was a whole big context missing: that original load of "last_pid" 
into "last" at the top of the function, far outside the patch.  And in 
this case I don't think splitting out the trivial cmpxchg() loop would 
help that problem - that would just make the "load original" part of the 
big picture be even further away from the final "replace if same" part, 
and I think _that_ is a much more critical part of the subtleties there.

So I had to read the patch _and_ go read the code it patched, in order to 
at all understand what it did. I think the patch explanation should have 
done it, and I also think this would need a bit comment at the top.

[ In fact, I'd argue that the _old_ code would have needed a big comment 
  at the top about last_pid usage, but i somebody had done that, they'd 
  probably also have seen the race while explaning how the code worked ;]

So having looked at the patch and the code, I agree with the patch, but 
I'd like some more explanation to go with it.

[ Or Ted's version: as mentioned, I don't think the complexity is actually 
  in the final cmpxchg loop itself, but in the bigger picture, so I don't 
  think the differences between Ted's and Salman's versions are that big ]

			Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ