Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4264684imd; Mon, 29 Oct 2018 22:01:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5dEA86n+c7F4kaL80Htx2ISvWWP+fY2dEYfxtAdoXgXgO5D8l0rNDG/zIOe1BOdS36ZJ82H X-Received: by 2002:a17:902:76c1:: with SMTP id j1-v6mr10824245plt.338.1540875702252; Mon, 29 Oct 2018 22:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540875702; cv=none; d=google.com; s=arc-20160816; b=ScbmAx1rewJ8PoIol9ncUpdT8j2ivfsY6LFr5EOU0oXMQHBYeRsmyszDHDvog6K47U VKS/d7L6EDmvNYL2cWn89uF8JHA67b8/vTmU/u4jZyVfG0DgkzI2YjCwVQc19jg5HTEP SixQbk/vQSCpZY3oLcarCt/bEpM1z7mvQ8kCwdi/yLnzKeLA5M9/cj3RGqdTi7JBZ0B0 6XfTy9hpxZpBNDojYz//zb+GA/xhd9IzYux/Kp04e65b0a+nnc/LpyQY7vjeAVOwteeX BBe/j4or39zC3yOINFo3km0bJnqgdnCXSZymp06DJ92uVBMxDmzi6tmK3U+UXEzAVEb1 xMnQ== 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=5sTcvTr04CoY9A2zDK4qwJhfhrBlnXG3JU28Fb/pXHc=; b=e0waSZWFkFbniAxkQHfj3y0Z2h0Xw+SFPw6MpMlUYkAfBqhyiQGm6uot0R2eBbcw3+ fYU/WZljrhcnT6z1/5bwSQY/FcBJJRpW95HX8yvlqgOmuo+0Z9oRra4fNVzKfmYvgUin ER1heUKczDf3159Kc3lhOCbizuwWSSExZ6LFOjNxzKHvcdyFUGzfG8mdQznYMTLYgz0n 3oYSQh+jut2ezcK2klJTBpYz5RaAASncpORE7wzTybTyXHi8qmUlKYPLdU0pZq1wxl7y 9cRMmfMlDd2lGng4eWp5YL+Wv//VHcHyoyTZ6lUk+mye5SgR/6OayaPG43UCOgiIRyb4 jbIw== 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 y190-v6si22744804pfy.147.2018.10.29.22.01.05; Mon, 29 Oct 2018 22:01:42 -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; 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 S1726158AbeJ3NwQ (ORCPT + 99 others); Tue, 30 Oct 2018 09:52:16 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:54976 "EHLO mx1.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbeJ3NwQ (ORCPT ); Tue, 30 Oct 2018 09:52:16 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id B0F9E4296F; Tue, 30 Oct 2018 06:00:20 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id frgYADXi97fT; Tue, 30 Oct 2018 06:00:18 +0100 (CET) Date: Tue, 30 Oct 2018 16:00:12 +1100 From: Aleksa Sarai To: Daniel Colascione Cc: linux-kernel@vger.kernel.org, timmurray@google.com, joelaf@google.com, surenb@google.com Subject: Re: [RFC PATCH] Implement /proc/pid/kill Message-ID: <20181030050012.u43lcvydy6nom3ul@yavin> References: <20181029221037.87724-1-dancol@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wxjaav5rzxv6e2sm" Content-Disposition: inline In-Reply-To: <20181029221037.87724-1-dancol@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --wxjaav5rzxv6e2sm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-10-29, Daniel Colascione wrote: > Add a simple proc-based kill interface. To use /proc/pid/kill, just > write the signal number in base-10 ASCII to the kill file of the > process to be killed: for example, 'echo 9 > /proc/$$/kill'. >=20 > Semantically, /proc/pid/kill works like kill(2), except that the > process ID comes from the proc filesystem context instead of from an > explicit system call parameter. This way, it's possible to avoid races > between inspecting some aspect of a process and that process's PID > being reused for some other process. (Aside from any UX concerns other folks might have.) I think it would be a good idea to (at least temporarily) restrict this so that only processes that are in the same PID namespace as the /proc being resolved through may use this interface. Otherwise you might have cases where partial container breakouts can start sending signals to PIDs they wouldn't normally be able to address. > With /proc/pid/kill, it's possible to write a proper race-free and > safe pkill(1). An approximation follows. A real program might use > openat(2), having opened a process's /proc/pid directory explicitly, > with the directory file descriptor serving as a sort of "process > handle". I do like the idea of holding a dirfd to /proc/$pid to address processes, and it something I considered doing in runc. (Unfortunately there are lots of things that make it a bit difficult to use /proc/$pid exclusively for introspection of a process -- especially in the context of containers.) --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --wxjaav5rzxv6e2sm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEb6Gz4/mhjNy+aiz1Snvnv3Dem58FAlvX5VwACgkQSnvnv3De m58W1RAA4BTdMe+UnblWb6o2e7KZ+pRPIFZJ9eJJQ64yhw4i0yEu/bBCjsLccl51 uhVBZSKY4Gg9BpzuyqeFyDdZoSa4Ifcm1oeGlWq1ZKoBteq7lMxlqJ7aX9IydhLD fsZ807py+YNIeaESyGcP2cKIJAsCkOnoGtSvNvUI/f3UyduS4PsjVu4Dn0Io1t2z FDAx5xA283Em2qy8MXrVZ7pKc6wkynGnKX2Jo8Vhp2oovwSImc5onVNSX8VTV1Uh uEwSd2ir5oRM/YTJP9aCoCLC4aRi7oBxEqcEgLtuIxuQn8h8XMsq0Nja3mnYgEaF c17AJ996fX9SX0vP2lWFAHNGjqlbe8VIeq2terv3Jc7aNAyMCY7uJZM2dFcZKHnd Ao5sdvBQ/3k/HD+KGJ58KPoGq7XJ+LwgfZGiajsla0DaaSRAO5N7vIEtBLiBu9t7 QVHFzys4N2LQ1B32kOSQqYxFwdBjH7i63msJtjZb+CxN/liroqzuc+W1TeH1lJMI h1ybxiWGS098HGPw2caZ06zPbXKjU4JMviZ+xhFK8ebwXA2sYtW+ONEncXdMQwBX wXs2Hfg9b4CvKvmSQpBitphb8skV1B8m2wZ1hgh56hR/F1A2HqT3oYTPdGfjBxoK /ryxBlX+jVy24Jg3AK4n+w3SpBG55mVCLCBhfOstfJcn9vcUqus= =X7U2 -----END PGP SIGNATURE----- --wxjaav5rzxv6e2sm--