Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp901786imu; Thu, 22 Nov 2018 07:05:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/WeFA51rNYwFtf7m+NAhA7h4F861OFxZtKomVaDbwVhzpWUxqB+pjaprhcyuQPM37PdMQPZ X-Received: by 2002:a17:902:6e16:: with SMTP id u22mr11423095plk.175.1542899111974; Thu, 22 Nov 2018 07:05:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542899111; cv=none; d=google.com; s=arc-20160816; b=hO5+JTjHpb5JESZHku6KXuUwhhYjC0XCptWzwB68OuKquS+OaDffbcr+bMO1iyIFuT cPwjDf0uCRvJjBY6eoh4RdJTEFD9TV4sfJJYuNP8fdQ/03Qx2gEMA02mJxQqeFYdjt2c TStFhsQ11y09oKSClR5o/Yox/hn3BuiGolD+k/DUg3G8Xl/CkBoTHjCAhq9uZel6/v66 PqkQ+ZyObhSjh/u8vsw12H9VtWKnv9aJC40iQsL7lL1f4vI4GzR9VuBBK2Kea84NemhB L7io0sJJddqds67Rzm8H9QQyzQJvsu5lvbVLkAqygJqSQR2mT5H4MSQIYvirdFA+KYSK P68Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8Xd491HEnuf+bk74bPJPG2oZIfbHa2OMGQrvUXvSbck=; b=eVRNNN8CgZEuTO1WDMI6V93FBa84SMaQ+ONmjNo8DV8HtvE8PawG0yiY5dAaX28VZv 2S8spkvQpfFPc1GCJSaSXJHcW726O1/yEbJ5Hvs0/dP0N/g6XINGq/0HPjHCA/Et90Jf xhtsycHVNFIDw31+zvf7B9mB9jjyk3fCnFPMB9F8qikCXOCH98TU5rnnpjT5OCyZ97A+ RB55mmWiNL3OyJ6QxDHWG6748ZkPVRDZuwTn50z2a9DUn3uiVWKXgZMm2zc+L/ruR0Fr c6Jd5GSoq3y6sDs63RgPBR7NWp4mVCVNqzvcquAad7LEE7ReSvVUkb3F9g1FmLATzuXU GvPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="WB/vsaU4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4-v6si53203159pla.176.2018.11.22.07.04.55; Thu, 22 Nov 2018 07:05:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="WB/vsaU4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729854AbeKVMnn (ORCPT + 99 others); Thu, 22 Nov 2018 07:43:43 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:40158 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728243AbeKVMnm (ORCPT ); Thu, 22 Nov 2018 07:43:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8Xd491HEnuf+bk74bPJPG2oZIfbHa2OMGQrvUXvSbck=; b=WB/vsaU4L3jCME/FT/RF9a92C Dtbn+4eIZFZZcL7pDr2n2zGBfSL0EjRLgMaNRTubgRja7hX7jLPJWI5TMOqC0bIPa0bVIEAfaA5zv aBzuA53gR4lyaNZRLmSKNMiGLdRbrHvFeAlkF0b/3idCrT/mD+eX7YkMh4JsWlaL8XNmdPch7JZwl QMUkUwbeYY4fdDsyTPo1xBfFSROgyXuc0vleRxpwq4XwlknNxteftqzxsO31rR95WYs8ozAl783ZB QeXuREqORPNNAi+ovGkaLi4Eo7Vntwg73k2V06T3nYC1t1D4feikjn4DXFp8sBtbUMBSfp1jjHRJ4 88BLmrUxg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPeO2-0006IA-0P; Thu, 22 Nov 2018 02:06:34 +0000 Date: Wed, 21 Nov 2018 18:06:33 -0800 From: Matthew Wilcox To: Daniel Colascione Cc: linux-kernel , Linux API , Tim Murray , Primiano Tucci , Joel Fernandes , Jonathan Corbet , Andrew Morton , Mike Rapoport , Roman Gushchin , Vlastimil Babka , "Dennis Zhou (Facebook)" , Prashant Dhamdhere , "Eric W. Biederman" , rostedt@goodmis.org, tglx@linutronix.de, mingo@kernel.org, linux@dominikbrodowski.net, pasha.tatashin@oracle.com, jpoimboe@redhat.com, ard.biesheuvel@linaro.org, Michal Hocko , David Howells , ktsanaktsidis@zendesk.com, "open list:DOCUMENTATION" Subject: Re: [PATCH] Add /proc/pid_generation Message-ID: <20181122020633.GN3065@bombadil.infradead.org> References: <20181121201452.77173-1-dancol@google.com> <20181121203150.GK3065@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 12:38:20PM -0800, Daniel Colascione wrote: > On Wed, Nov 21, 2018 at 12:31 PM Matthew Wilcox 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?