From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B25C5C04A6B for ; Sun, 12 May 2019 13:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 764E82133D for ; Sun, 12 May 2019 13:39:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbfELNjG (ORCPT ); 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--