Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6164006imd; Wed, 31 Oct 2018 07:46:02 -0700 (PDT) X-Google-Smtp-Source: AJdET5dz8BH7xHNfbCkH9ArB9xCzv5wsFAU28/a5Th0QlkN3wbsC5rpx6Ozw4SBKUUcWsu93CB63 X-Received: by 2002:a62:6486:: with SMTP id y128-v6mr3872323pfb.76.1540997162069; Wed, 31 Oct 2018 07:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540997162; cv=none; d=google.com; s=arc-20160816; b=ZaKMaUWE72p8m4F4nZZvh2WMc1fn8ntKzvB19Jyqefm+QEau2f5kFokrsWDrbA5I4Q Yh1OYadTDEnVaRaYfS7ojwVKbfTErJTUIF4wlbRC7DT5ttZ1ufz5BR87ASCXYOJRTh34 xgzYxu8WGBImKHzXVI4WHfKuYNXSDx/pOR0EeqGFobkVcD8vv/Xhj065t+CDRGju9UmG El/4WsJ647PwnQsdOuqLPEn4UJ2aPKIhTrKKmJp6sLsgciRqi79GZsXALC7FNutYBCUL EhIYABP8DgcPPj53f5oF0AthcbjzxMA1xB0CXQPGPLUxyZPPJ824+XCEmOWEM0qODFKY 7rdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=/TxP1yzwS9JKT/Ffr9q+gerXPK3mw3wPeLnkm/RcNtc=; b=d7dKrFMJ0WEGYxmFCnaNz7V6VTwdqVony2hioJ2VXB4++NTSaCwZ7C6Q2aCpuafdBt lnbQuNJ2WzbP7G9aji5nJlsSwZWWrFkkYgRUwU7hMK2+8YlJoKZr5BpbhTnN8NKGdYeA C+roYso+3QPINRTxAm9uRydvfG+0SENFcYV21pat7AI/NyNhL+xf6TRMyxh04kj3XFok SmHTXzVHCAffc6jAK2CjVvNS/lRhYcboPeOC6/WHTGDb2Q/PjWWURbb/FRxBulRlXpps +FjlcE1inZ6+ztc7VVK4OP+4cfhy8pz0SklSqZrKRNjcmaHS5Ch1lPLbC38Qs+/acpgy 6Cmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=EjfGd5dt; 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 w7-v6si25987981plz.23.2018.10.31.07.45.47; Wed, 31 Oct 2018 07:46:02 -0700 (PDT) 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=pass header.i=@joelfernandes.org header.s=google header.b=EjfGd5dt; 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 S1729676AbeJaXl4 (ORCPT + 99 others); Wed, 31 Oct 2018 19:41:56 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41629 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729650AbeJaXl4 (ORCPT ); Wed, 31 Oct 2018 19:41:56 -0400 Received: by mail-lj1-f196.google.com with SMTP id z80-v6so9012450ljb.8 for ; Wed, 31 Oct 2018 07:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/TxP1yzwS9JKT/Ffr9q+gerXPK3mw3wPeLnkm/RcNtc=; b=EjfGd5dtlN1TJvN4s7A2+CljT+7l8I9arV+J3SEl8HrG1r2QkggzVzIYwBpjwGbRN+ uCxCPO248IeerJQwPE5ibW8PXvNgYRn7kd8uH+4rP7XX8GlS3SO/KbFi7v5Zvc11ShGV dWBeiRKlKDDIZ7Ud533lKgtdB1X2MaZDBIlrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/TxP1yzwS9JKT/Ffr9q+gerXPK3mw3wPeLnkm/RcNtc=; b=Onb9lL7hhhLXvY9C/0G8ccq3qahJ09cRGQKkciXH486lPCC9QANYTdVxcJ1+/ugQA7 Y4eKYzzWIqCc95wD3uDL7NyUpub+FcwxncNklDfABMIC2pp/E9fbYogVUJ99yRbBgxMJ RtRjmFpQUgJ89nCldqyyUZU9mjK07OuMTxtc28ZXomRVdXMVDDAA5tjBqTqVzemXpF6H 7ZqP2kWbrK3fc971Ahg4roFXJbJVhOENLGuHRfGVegozf1vIGmSKcjTTF/VJs2ftVDy1 1/1rpmfuAQvVGAhLJNtnWeVuhkrICkjEhCHyUlIEhi3EXpAynpuoOyNu6l+2dat4bWw+ ybEg== X-Gm-Message-State: AGRZ1gKt8thHHoKf/K6lD1lZaWWQjitKR0jKEBObMGOmo/76s2eBSGG5 +2L5bCEcuMXhap3ZRFaMG2wEjGY0+2+bC/zVWejy6Q== X-Received: by 2002:a2e:4811:: with SMTP id v17-v6mr2213899lja.151.1540997015482; Wed, 31 Oct 2018 07:43:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:650a:0:0:0:0:0 with HTTP; Wed, 31 Oct 2018 07:43:34 -0700 (PDT) In-Reply-To: References: <20181029175322.189042-1-dancol@google.com> <4beaaae77bea4cc5b4cc15504331c9a9@AcuMS.aculab.com> <4ed9af67cf4a46708905d3f392344bcb@AcuMS.aculab.com> From: Joel Fernandes Date: Wed, 31 Oct 2018 07:43:34 -0700 Message-ID: Subject: Re: [RFC PATCH] Minimal non-child process exit notification support To: David Laight Cc: Daniel Colascione , "linux-kernel@vger.kernel.org" , "timmurray@google.com" , "joelaf@google.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 31, 2018 at 7:41 AM, Joel Fernandes wrote: [...] >>> > Indeed, to avoid killing the wrong process you need to have opened >>> > some node of /proc/pid/* (maybe cmdline) before sending the kill >>> > signal. >>> >>> The kernel really needs better documentation of the semantics of >>> procfs file descriptors. You're not the only person to think, >>> mistakenly, that keeping a reference to a /proc/$PID/something FD >>> reserves $PID and prevents it being used for another process. Procfs >>> FDs do no such thing. kill(2) is unsafe whether or not >>> /proc/pid/cmdline or any other /proc file is open. >> >> Interesting. >> Linux 'fixed' the problem of pid reuse in the kernel by adding (IIRC) >> 'struct pid' that reference counts the pid stopping reuse. > > This is incorrect if you mean numeric pids. See the end of these > comments in include/linux/pid.h . A pid value can be reused, it just > works Ok because it causes a new struct pid allocation. That doesn't > mean there isn't a numeric reuse. There's also no where in pid_alloc() > where we prevent the numeric reuse AFAICT. Bleh, I mean alloc_pid().