Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3278534imu; Mon, 19 Nov 2018 13:26:30 -0800 (PST) X-Google-Smtp-Source: AJdET5dP7aCb/8eOPC5NuE9HRf5xTUx85+UOPUDkKNcAEzpa3byO4b7cVlXI6ltNzU0ilyAZPzYm X-Received: by 2002:a63:ed42:: with SMTP id m2mr21786608pgk.147.1542662790446; Mon, 19 Nov 2018 13:26:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542662790; cv=none; d=google.com; s=arc-20160816; b=K75snAzi0PGDJVKRYoJVpXibt8q0y+9+xCkLPNB3UgFXsxTxmAFOxVtf1dWOVrMzpq OnZlZLhDIBut3Zq8QMQUkcwfgps3u+ZJSVjXNTEvEvcTAdIWmyzmVkCDl5HTY0qAbau/ XSWvBZQX39GHVpWbBGLH2zw3N/ReDVufaKz01C7v99BYXZQ9j5T0f6ElpDBwjKO1xpUS LuQAHRBI01AbFUOJ6OPCDz5Lyuku483a5M89xe3bZGbHPyAaMd+3IWaJAsq401pV5X1b YYUN3s1ywIfEPN+g9U+dC2f68FEZtJ4tfvqCfSDRCiqYKaorbVyyyxS9LlCaY0XVQ/41 3WBw== 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=h3rrxJF1mdBIATArtdUKeJLT42jCSJaGD9jfgfUvLdM=; b=t1W5tsFMsrbwNpdTuyFLa8b7vfkV7L9c1EmW4dmo9NXM9aaeehaVnuJJpCH5/RnsAr x0gTbvwYOdsLjPPNz/A+sDOzKsU2esYKlx9nNPIKi7L+BMw2rWE/PEdFEJR6V3J9Ga35 ibiHj6x4Ew4sQQL+U9sXGqiyMMbLFpzrg0+NR/TjI+1lZKpUbfVneqFsZyeG2wzllCAB tNfhQn0KQKXbEUideRB40ti8co+AAtitcqsP2vJPiuIcgClya/X7eKdt9za+xSuTPfuP FwRL0+undngVdAMuOEFsoe5zizxe2sHo9VTPesahvIB2hlCvRkp5/jmgtpUKgGIvnQXw Ezug== 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 s71si6355315pfk.105.2018.11.19.13.26.14; Mon, 19 Nov 2018 13:26:30 -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 S1731031AbeKTHvH (ORCPT + 99 others); Tue, 20 Nov 2018 02:51:07 -0500 Received: from mx2.mailbox.org ([80.241.60.215]:40756 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730141AbeKTHvH (ORCPT ); Tue, 20 Nov 2018 02:51:07 -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 mx2.mailbox.org (Postfix) with ESMTPS id D8CC8A24DF; Mon, 19 Nov 2018 22:25:30 +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 nSyCXggi8Ycz; Mon, 19 Nov 2018 22:25:28 +0100 (CET) Date: Tue, 20 Nov 2018 08:25:19 +1100 From: Aleksa Sarai To: Christian Brauner Cc: ebiederm@xmission.com, linux-kernel@vger.kernel.org, serge@hallyn.com, jannh@google.com, luto@kernel.org, akpm@linux-foundation.org, oleg@redhat.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, dancol@google.com, timmurray@google.com, linux-man@vger.kernel.org, Kees Cook Subject: Re: [PATCH v1 2/2] signal: add procfd_signal() syscall Message-ID: <20181119212519.yqh7qldznqwct3dv@yavin> References: <20181119103241.5229-1-christian@brauner.io> <20181119103241.5229-3-christian@brauner.io> <20181119202857.k5zw742xjfrw677j@yavin> <20181119205518.btew3vxwgva4w3zh@brauner.io> <20181119211810.73ptfhnwdmkngfi4@yavin> <20181119212126.u2nkijmula6wcfqi@brauner.io> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zpidgantrji2nrnp" Content-Disposition: inline In-Reply-To: <20181119212126.u2nkijmula6wcfqi@brauner.io> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --zpidgantrji2nrnp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-11-19, Christian Brauner wrote: > On Tue, Nov 20, 2018 at 08:18:10AM +1100, Aleksa Sarai wrote: > > On 2018-11-19, Christian Brauner wrote: > > > On Tue, Nov 20, 2018 at 07:28:57AM +1100, Aleksa Sarai wrote: > > > > On 2018-11-19, Christian Brauner wrote: > > > > > + if (info) { > > > > > + ret =3D __copy_siginfo_from_user(sig, &kinfo, info); > > > > > + if (unlikely(ret)) > > > > > + goto err; > > > > > + /* > > > > > + * Not even root can pretend to send signals from the kernel. > > > > > + * Nor can they impersonate a kill()/tgkill(), which adds > > > > > + * source info. > > > > > + */ > > > > > + ret =3D -EPERM; > > > > > + if ((kinfo.si_code >=3D 0 || kinfo.si_code =3D=3D SI_TKILL) && > > > > > + (task_pid(current) !=3D pid)) > > > > > + goto err; > > > > > + } else { > > > > > + prepare_kill_siginfo(sig, &kinfo); > > > > > + } > > > >=20 > > > > I wonder whether we should also have a pidns restriction here, since > > > > currently it isn't possible for a container process using a pidns to > > > > signal processes outside its pidns. AFAICS, this isn't done through= an > > > > explicit check -- it's a side-effect of processes in a pidns not be= ing > > > > able to address non-descendant-pidns processes. > > > >=20 > > > > But maybe it's reasonable to allow sending a procfd to a different = pidns > > > > and the same operations working on it? If we extend the procfd API = to > > >=20 > > > No, I don't think so. I really don't want any fancy semantics in here. > > > Fancy doesn't get merged and fancy is hard to maintain. So we should = do > > > something like: > > >=20 > > > if (proc_pid_ns() !=3D current_pid_ns) > > > return EINVAL > >=20 > > This isn't quite sufficient. The key thing is that you have to be in an > > *ancestor* (or same) pidns, not the *same* pidns. Ideally you can re-use > > the check already in pidns_get_parent, and expose it. It would be > > something as trivial as: > >=20 > > bool pidns_is_descendant(struct pid_namespace *ns, > > struct pid_namespace *ancestor) > > { > > for (;;) { > > if (!ns) > > return false; > > if (ns =3D=3D ancestor) > > break; > > ns =3D ns->parent; > > } > > return true; > > } >=20 > That can be done without a loop by comparing the level counter for the > two pid namespaces. If so, we can refactor how pidns_get_parent() and family work. :P But yes, I agree with doing the above check. --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --zpidgantrji2nrnp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEb6Gz4/mhjNy+aiz1Snvnv3Dem58FAlvzKj4ACgkQSnvnv3De m5+vyQ/9GOPT3/WkZ6fIioaCLZF1BAQUrF/fxKBg37g2IgUNZPQM0AQ7bj7JF0Up kEdujH6PGyCgbvU3xPwPzcL1o/imFH4/007apqvo6zKfXKG5CpYVFlFa+AEVKX0w FYjsv7MHvnM2xaVLnt9/0UWdckzg6G0jtpDPYoDNMjrRdzhppNVl39iJhfovZehe 4f7FA/jPncrsX+NWxlhhWvilkCE1M5c7C7jZI4Eye7SLVSvK/PdJqqzvaMkWx+up J8Jt3wFyWIdKg2DYrwaoJuYmlVuVObydSEy/fswqlY/7S25Ddp3Le1zBFYj/o3p0 khnVBWf/KAwRe7Dkiv9XXuchMsMu6P8SfsmvWFLLbRV6HKzYS0JJU5blRabcEHuS oboBw7LyK3vBmV34xpiXRw7LtI3Vm43zsLuc6WxBep8FeL0arCjTzdiMcu0f890q qoxttlsZXG3FksoQFnxnzzQBUSEjL9GW1LtJ/Ldcyh4PbyC4B2mb84hEtzKVT9Xr FIzRz1XHe4KoL2jfn+w09mena4lla6e9FGLyxavTAf0psObZwzF8kIKgn+gGQUjG dVHFYNJpV1sfltcl+dG+x8Vl79IKgIaqwMRqqncxlbmNAFxn9PUsInVKGKY1C+O7 U1pBphPN85Yo3ciAKo4IRMR6AQMwCY4IUCjNgPtMHelZiVihZ7o= =kRaK -----END PGP SIGNATURE----- --zpidgantrji2nrnp--