[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181122020633.GN3065@bombadil.infradead.org>
Date: Wed, 21 Nov 2018 18:06:33 -0800
From: Matthew Wilcox <willy@...radead.org>
To: Daniel Colascione <dancol@...gle.com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
Linux API <linux-api@...r.kernel.org>,
Tim Murray <timmurray@...gle.com>,
Primiano Tucci <primiano@...gle.com>,
Joel Fernandes <joelaf@...gle.com>,
Jonathan Corbet <corbet@....net>,
Andrew Morton <akpm@...ux-foundation.org>,
Mike Rapoport <rppt@...ux.vnet.ibm.com>,
Roman Gushchin <guro@...com>, Vlastimil Babka <vbabka@...e.cz>,
"Dennis Zhou (Facebook)" <dennisszhou@...il.com>,
Prashant Dhamdhere <pdhamdhe@...hat.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>, rostedt@...dmis.org,
tglx@...utronix.de, mingo@...nel.org, linux@...inikbrodowski.net,
pasha.tatashin@...cle.com, jpoimboe@...hat.com,
ard.biesheuvel@...aro.org, Michal Hocko <mhocko@...e.com>,
David Howells <dhowells@...hat.com>, ktsanaktsidis@...desk.com,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>
Subject: Re: [PATCH] Add /proc/pid_generation
On Wed, Nov 21, 2018 at 12:38:20PM -0800, Daniel Colascione wrote:
> On Wed, Nov 21, 2018 at 12:31 PM Matthew Wilcox <willy@...radead.org> wrote:
> >
> > On Wed, Nov 21, 2018 at 12:14:44PM -0800, Daniel Colascione wrote:
> > > This change adds a per-pid-namespace 64-bit generation number,
> > > incremented on PID rollover, and exposes it via a new proc file
> > > /proc/pid_generation. By examining this file before and after /proc
> > > enumeration, user code can detect the potential reuse of a PID and
> > > restart the task enumeration process, repeating until it gets a
> > > coherent snapshot.
> > >
> > > PID rollover ought to be rare, so in practice, scan repetitions will
> > > be rare.
> >
> > Then why does it need to be 64-bit?
>
> [Resending because of accidental HTML. I really need to switch to a
> better email client.]
>
> Because 64 bits is enough for anyone. :-) A u64 is big enough that
> we'll never observe an overflow on a running system, and PID
> namespaces are rare enough that we won't miss the four extra bytes we
> use by upgrading from a u32. And after reading about some security
> problems caused by too-clever handling of 32-bit rollover, I'd rather
> the code be obviously correct than save a trivial amount of space.
I don't think you understand how big 4 billion is. If it happens once a
second, it will take 136 years for a 2^32 count to roll over. How often
does a PID roll over happen?
Powered by blists - more mailing lists