Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4556215imu; Tue, 25 Dec 2018 04:09:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN5e3mP4yFFpFGof3GrUQAL5b/GUztYKSu9OuVLovjppKc5yW9gkbgkYUx5JTVcJriozQB7n X-Received: by 2002:a63:8c0d:: with SMTP id m13mr15609703pgd.422.1545739764911; Tue, 25 Dec 2018 04:09:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545739764; cv=none; d=google.com; s=arc-20160816; b=FFjlKUfgGnTljaaPUuwnO6KQiUkSgqSCYGevEFJBSLHYlunctbICdOrLw5mBRJb/NU ubayKdAVMYubC4aDBovHgojA4Igc7fd85pDHWoFkIPMO6zT2ozkS/MyA3bkbqM7ZlpIb NXIrzaE56eNcKy/J8CFhoehPTu+INsfE2ql9Unn3RIhJVXsKCMyS3hpK2MA8a31LSxBr txjR/+/EC/tzx+FnvF3xPNAEmL1oZFyXshaEASffOkvSyeNZz4MB2EXaBResoZAjYyjj 87aXkJhqI2sWB4sckXATSma50PcY52JxTi4TVcSV+CJRVP4/1bxDJ/Yb+R7NpVxTvApT VszQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=JConU3GVwx4C7kpaojTjsCCHgzpSymNsc3Msaa3b8P8=; b=SKnFYWGljTw4imKJVtUycreu0iHfMrQTFhbpCVpgfEDf8wIZyS6J6+9CIi9xDL7049 turHgPDPsjIwegHQAxmEcM/N6MwrkbYh+bjtUATvgmIbQITZVXdQGQD7eMR5TstSOl5y ehSomDtggiDdMd5rUetUQ9ad+cMKLTzJ0nfojzmblclo//GBmXlUP3EX27JMp3T8yCdl snWKVwAt/aBob+ZP6+idLx+B3J8Z1E7MyeZZFKFz2KvV9cgd++OL44JYgN9aH0xCHREn FoQEgQGvXEJaTvYc2vQfr5yIgh3waf6cGJdE4nBG5qdB1ST5JDxSo5bDzlhfn0fN+QZf 8TpQ== ARC-Authentication-Results: i=1; mx.google.com; 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 s36si27214167pld.46.2018.12.25.04.09.09; Tue, 25 Dec 2018 04:09:24 -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; 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 S1725896AbeLYMIT (ORCPT + 99 others); Tue, 25 Dec 2018 07:08:19 -0500 Received: from mx1.mailbox.org ([80.241.60.212]:18600 "EHLO mx1.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbeLYMIT (ORCPT ); Tue, 25 Dec 2018 07:08:19 -0500 Received: from smtp2.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id D62924A16E; Tue, 25 Dec 2018 13:08:15 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id C9l0FC2a7MHe; Tue, 25 Dec 2018 13:08:13 +0100 (CET) Date: Tue, 25 Dec 2018 23:07:57 +1100 From: Aleksa Sarai To: Lai Jiangshan Cc: Christian Brauner , Florian Weimer , Andy Lutomirski , "Eric W. Biederman" , LKML , "Serge E. Hallyn" , Jann Horn , Andrew Morton , Oleg Nesterov , Al Viro , Linux FS Devel , Linux API , Daniel Colascione , Tim Murray , linux-man , Kees Cook Subject: Re: [PATCH v2] signal: add procfd_signal() syscall Message-ID: <20181225120757.37w37lmyhxo6kekl@yavin> References: <746B7C49-CC7B-4040-A7EF-82491796D360@brauner.io> <20181202100304.labt63mzrlr5utdl@brauner.io> <8736rebl9s.fsf@oldenburg.str.redhat.com> <20181203180224.fkvw4kajtbvru2ku@brauner.io> <874lbtjvtd.fsf@oldenburg2.str.redhat.com> <87y392h4b7.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="q4jdymnvoez454lh" Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --q4jdymnvoez454lh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-12-25, Lai Jiangshan wrote: > On Tue, Dec 25, 2018 at 1:32 PM Lai Jiangshan > wrote: > > > > Is it possible to avoid adding any syscall? > > > > Since holding /proc/pid/reg_file can also hold the pid. > > With this guarantee, /proc/pid/uuid (universally unique identifier ) ca= n be > > introduced to identify tasks, the kernel generates > > a uuid for every task when created. > > > > save_pid_uuid_pair_for_later_kill(int pid) { > > /* save via /proc/$pid/uuid */ > > /* don't need to keep any fd after save */ > > } > > > > safe_kill(pid, uuid, sig) { > > fd =3D open(/proc/$pid/uuid); /* also hold the pid until close() if > > open() successes */ > > if (open successes and read uuid from fd and if it equals to uuid) > > kill(pid, sig) > > close(fd) > > } > > > > All things needed to be done is to implement /proc/pid/uuid. And if pid= can't > > be recycled within 1 ticket, or the user can ensure it. The user can use > > starttime(in /proc/pid/stat) instead. > > > > save_pid_starttime_pair_for_later_kill(int pid) { > > /* save via /proc/$pid/stat */ > > /* don't need to keep any fd after save or keep it for 1 ticket at mo= st */ > > } > > > > safe_kill(pid, starttime, sig) { > > fd =3D open(/proc/$pid/stat); /* also hold the pid until close() if > > open() successes */ > > if (open successes and read starttime from fd and if it equals to s= tarttime) > > kill(pid, sig) > > close(fd) > > } > > > > In this case, zero LOC is added in the kernel. All of it depends on > > the guarantee that holding /proc/pid/reg_file also holds the pid, > > one of which I haven't checked carefully either. > > >=20 > Oh, Sorry, I was wrong, the pid isn't reserved even when > the fd is kept in the user space. And I'm sorry that I had > replied to an "old" email thread. Don't worry, this was a common point of confusion during this (and sister) threads. All the fd ensures is that access through that fd will give you -ESRCH if the process is gone (and if the PID is reused it will still give you -ESRCH). --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --q4jdymnvoez454lh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEb6Gz4/mhjNy+aiz1Snvnv3Dem58FAlwiHZ0ACgkQSnvnv3De m591UxAAsfeV1mki8pGjp8ePXOEqSApU/bV4+S6N+8Xt7yZIAdzAMspeaibxXJ3r zSqflUgH/KeYH72gaRSseAk14R30jt9jjf/Q5P7aPuN97kZsf/0+j+il5wj2mTDa vXnopUyCeQpbcTcM4YktBvgZC1ZjTj99Jhy94petxRfFtQOurW+wblx4MF/6+/y3 3rpf8TyFTez9FCV+LLvwNekIyLVlG8QeuWl1N14qgdyNE+NWOETZup2QxhKBsoDj fxZmNKD1ChwzQaKQNm/zSGlh1Xkm9R/SnM2Nr3YWsxdbboyigeRceDv5HDqltz/9 AN0s12V7iGcg5n4s4hyj+wWQKW7VJHEvxZ0aVjD+zPeSCwM6w2oTH3QcV7oCz3gN tj5i1hOnFrsC/HszxFsXdQAYgaidAmO5lPpULasoTonsTNNRSUOnMuUMZ3CnAowB OxmWrAKubLCzI0k4SqMlaQtbHkeqB3nlUBgTEgOUfLaXUYW1xQYNgmlZvbT5OG1e ytQc/5E+2PaSLTLp6S/2AuBm8a7JOm13DZ341p+pWVGLrN5/L19CSTrtpJfIzMqT SUKC7nkRse557h96bZnc38t/G0u7Ec4QIdNYqqrIcUFelyoS0WkBWcdpwi+ZH5n6 V1jLxVD3OonKoPqcTSZOBDwaw9k0QVbk/exxn9GM41NJI9fc78k= =3gq/ -----END PGP SIGNATURE----- --q4jdymnvoez454lh--