Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4170372yba; Sun, 12 May 2019 06:40:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFpfETYHnX9h6CnMgPBdmMfCYptjdSL/pt5KXtaONtMzaYI/zxo/bHfqrK2yoSJThJKUFH X-Received: by 2002:a17:902:294b:: with SMTP id g69mr25293016plb.57.1557668411215; Sun, 12 May 2019 06:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557668411; cv=none; d=google.com; s=arc-20160816; b=xyljYDZ9k5ZNcmydNzq7rzHTLvGuFTu4ubh0x5x+Gfk2RuQbSFqtzGhELgBCU+nvKL soOu63XvUvUjnYGLyEzxAcJDLgqBA/aRbdzCwSk4eg674/VFWl3uU4P/pfoJmArW65l9 NCnTF3RHZ9+OZMSxcH7Yy6DADgRnt90XZgUWhAotF65Yb3SgQCm1Hxb3zs1N2kXWJRWy KlcaHg25KXyCeLuIO96hckBARYRvykp0I4L9AIJm+h0KiXkRt/5nT0TQ/sdMEL/UrUW6 +ev8fiBh/nzRjOPeOBbpXxosUMIxn/dTfAWI4NCeSXTk2znDSY/dXnrVkCdes2I7WWPH ieQA== 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=BzLI2p13KqbBXlGaVNdOpW+WLFMNioD+3Jwk5b3dOuU=; b=IC5oNjTDbWXP9/Cbot18ubNGSDLchpHCRBxwCCBuC5X8HVSIprxm5CvGHV66F5L9tL 6VcSEvGbhFA7m5q/xzzCNN6GGEBguaHWHJ5Q7GrxavxCawAzeEacijZbWV2vfFZ7zPjr OjJ5XqABKc0kkzAsug0rMxGyIXR38Y1ccBt0gQEiRyFm7AErVouuVXxEgjdaakqTA6CI n+QB6DQxYrTEzfK2jaPZbnVv+VrkNs1F1pLCdGb4fq52mOJOkFQH5JnmbEszbAglSGX9 lE1S1CqiE7VySeLF7JR8l7YetqIE2gszlJecT1KzkXR+++3NeGa9W8P2iN09dsyGtg63 XbsQ== 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 h38si14648338plb.259.2019.05.12.06.39.54; Sun, 12 May 2019 06:40:11 -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 S1726761AbfELNjG (ORCPT + 99 others); Sun, 12 May 2019 09:39:06 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:16568 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbfELNjF (ORCPT ); Sun, 12 May 2019 09:39:05 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id B4DA1A0021; Sun, 12 May 2019 15:39:02 +0200 (CEST) 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 CSOl9DeYISN9; Sun, 12 May 2019 15:38:42 +0200 (CEST) Date: Sun, 12 May 2019 23:38:26 +1000 From: Aleksa Sarai To: Linus Torvalds Cc: Andy Lutomirski , Andrew Lutomirski , Jann Horn , Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Eric Biederman , Andrew Morton , Alexei Starovoitov , Kees Cook , Christian Brauner , Tycho Andersen , David Drysdale , Chanho Min , Oleg Nesterov , Aleksa Sarai , Linux Containers , linux-fsdevel , Linux API , kernel list , linux-arch Subject: Re: [PATCH v6 5/6] binfmt_*: scope path resolution of interpreters Message-ID: <20190512133826.fcmfiqze7dnetews@yavin> References: <20190510204141.GB253532@google.com> <20190510225527.GA59914@google.com> <9CD2B97D-A6BD-43BE-9040-B410D996A195@amacapital.net> <20190512133549.ymx5yg5rdqvavzyq@yavin> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="upyx5avrpqh45pmb" Content-Disposition: inline In-Reply-To: <20190512133549.ymx5yg5rdqvavzyq@yavin> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --upyx5avrpqh45pmb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-05-12, Aleksa Sarai wrote: > On 2019-05-12, Linus Torvalds wrote: > > On Sat, May 11, 2019 at 7:37 PM Andy Lutomirski w= rote: > > > I bet this will break something that already exists. An execveat() > > > flag to turn off /proc/self/exe would do the trick, though. > >=20 > > Thinking more about it, I suspect it is (once again) wrong to let the > > thing that does the execve() control that bit. > >=20 > > Generally, the less we allow people to affect the lifetime and > > environment of a suid executable, the better off we are. > >=20 > > But maybe we could limit /proc/*/exe to at least not honor suid'ness > > of the target? Or does chrome/runc depend on that too? >=20 > Speaking on the runc side, we don't depend on this. It's possible > someone depends on this for fexecve(3) -- but as mentioned before in > newer kernels glibc uses execve(AT_EMPTY_PATH). >=20 > I would like to point out though that I'm a little bit cautious about > /proc/self/exe-specific restrictions -- because a trivial way to get > around them would be to just open it with O_PATH (and you end up with a > /proc/self/fd/ which is equivalent). Unfortunately blocking setuid exec > on all O_PATH descriptors would break even execve(AT_EMPTY_PATH) of > setuid descriptors. >=20 > The patches I mentioned (which Andy and I discussed off-list) would > effectively make the magiclink modes in /proc/ affect how you can > operate on the path (no write bit in the mode, cannot re-open it write). > One aspect of this is how to handle O_PATH and in particular how do we > handle an O_PATH re-open of an already-restricted magiclink. >=20 > Maybe we could make it so that setuid is disallowed if you are dealing > with an O_PATH fd which was a magiclink. Effectively, on O_PATH open you > get an fmode_t saying FMODE_SETUID_EXEC_ALLOWED *but* if the path is a > magiclink this fmode gets dropped and when the fd is given to > execveat(AT_EMPTY_PATH) the fmode is checked and setuid-exec is not > allowed. =2E.. and obviously /proc/self/exe would have an fmode ~FMODE_SETUID_EXEC_ALLOWED from the outset. The reason for this slightly odd semantic would be to continue to allow O_PATH setuid-exec as long as the O_PATH was opened from an actual path rather than a magiclink. --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --upyx5avrpqh45pmb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEb6Gz4/mhjNy+aiz1Snvnv3Dem58FAlzYIdIACgkQSnvnv3De m5/k3g//dQ2vldshSBgDRCYFp+NIbe3aezmy1kNqzKMMXgcsYT3mIrfWIxjG7YE5 PP9p1S71mRdCKTqsFBQgbDDyndrB4xM2i+twGDiGFS7w9zjL3XerilU1zGsasARI pO2c7q7q/yV3eojlUsjM1t+RoCP98mvNAqTSIaA9EwsoVGYclO6sySolqhRzYtiQ e4IxuO/6PO2iJ2q1U/dqHOIbccklkDtv3Axyr9ghs/IT8KLR6+Wz3oEUtq6nlhCT T0fyn5W3/iTSzXr5xM7Hh98IQ+3nvLgLf6a9RknjtLFPusnrc6FrkwfpJgEPNN6D N1nhoJZu7SFbMzAuRrkLdyCX/VSklzlfrpqXJkOg5GlKTP/sPRGYF+4RRbloYrkm 8pNnklo/iMeeDTS66ReDZJ3G7W6J0YjayC6IDFZTj2hlqSBxiBr6xdN1q/3IbH5e DnWvpohGw9hiihQy1crSSw8/JLEw0UOLtUFCd8F9BgX73bFOEVh21yITPIQXdLDS D1eKM4R8lk+9pVoMBWonwSc8fTIRpwt4i/i6eRG33aDjXqFbcNiYMRK8S6FiaQVH Vb1S5CEiYY71izXMPaqXY3LLhMpSQ+5lz3FHmrQrCejTFUmWuFclS/8woBbXFgg8 3hOD5KIGYIe+hCIQXzLM3FkdykiGTdsAoPUCSeLCaKe9goTLy5s= =2jNp -----END PGP SIGNATURE----- --upyx5avrpqh45pmb--