Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1246922imm; Thu, 4 Oct 2018 10:21:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV63FrrdeVzJEBub1lqM+NyHVyHqccTcAu7MKPTMfQdjcOnJTzMqAOOuDOGiKgotN1zhOkPAz X-Received: by 2002:a63:e443:: with SMTP id i3-v6mr6671045pgk.381.1538673699388; Thu, 04 Oct 2018 10:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538673699; cv=none; d=google.com; s=arc-20160816; b=KDGLgj8U2TMxdE0qrsxNvarJu7NB/7emGepuVmQwuhVveGHA0q+d1DQAS2LxdPGfNr G87wWlxUrHy8bC2xNWg21zqve9Wju/zQYqhcYlaHLB21MzcP3V+2muxYUat3uYVwDGXG nBaMoVIYRWHUqfhf4n3aCenjjtp8UOo5cDCjKkFZd35uTxM0051KKll1TtVzMwWu8wQH BjdMZbXJZ7wFjj9t2j+fvKaExIj4T5WaXJ7HptEuX3mkrHuCIFaVF6Ithjs1AJgwrWST /kJB/HQeLBNPrvrMJ9w4LEsHOYK7I3G+jUVesTrJ70iywlm0owP8ZIn9SFnNHU0jPniG O2RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mg/oh8t/Ds8Fq0VnewlBzCB2UjYG2eg4P9SikZmW0qo=; b=Lmkp25td6Gxnmc6r2a3sWL2b1HeDXx1tFsqu4IccnNbzryQ4S0i7RrBLD41UQibeBi mAGhEwl59ZtPmi6wDuAbI4MSAMIld1s0Tb6l80tESFCXNEWZwkyyUpGTWGlgUBiWEW3u LVDG1/TFE/QsAs2NfY7QDJ6U7TZnZfgJmM7Krqeg9rVyRm+AnrX5OZNQiTjBdcStAhC4 qLQv8Rna5EGENb6z0/weVzQLm220CDYSvPgLybiDkXoJgfx3dBpHELYNvjJ1JsK9fWhr kPrntZNFKG9Gp3FBQ1qMpbE32L9REIDw83mNvrfNDkoTXLqzTzmQdeVVFEUaUrcon184 ffuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=MWRjuo9H; 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 k10-v6si5430705pgj.381.2018.10.04.10.21.24; Thu, 04 Oct 2018 10:21:39 -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; dkim=pass header.i=@brauner.io header.s=google header.b=MWRjuo9H; 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 S1727837AbeJEAPN (ORCPT + 99 others); Thu, 4 Oct 2018 20:15:13 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45228 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727443AbeJEAPM (ORCPT ); Thu, 4 Oct 2018 20:15:12 -0400 Received: by mail-wr1-f68.google.com with SMTP id q5-v6so10759012wrw.12 for ; Thu, 04 Oct 2018 10:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mg/oh8t/Ds8Fq0VnewlBzCB2UjYG2eg4P9SikZmW0qo=; b=MWRjuo9HnSLQetw9mggskQOepok0ihVGKmQ7TdwCwtbd1nIIgdlq1DNDbNzbbdAD9t yJ5T28z+9r9H+O5oT/jCUO1Kl9a6bDpsNTjAhiAUKX3FKPnBl5+IlhIFTWFG0CIqzXmx fDKZ81B1LXi19ows8WPcehCB88IfVs92JBouDeH+wYGlAud0+7IKLqsjA47QUfk4CbSW MZTPeIxHhrk3OJEfv7pioOqYQ+4IJohiTIwZe+gYeglAtutBZgsQOG56CSOL4lvLmvjd CVA5ai5GDcRU3l1h2s8Dg92GF4TdhqqlFBs9td7yk4gJAi+PGD1jynpsK+NOlbscPvQp A9Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mg/oh8t/Ds8Fq0VnewlBzCB2UjYG2eg4P9SikZmW0qo=; b=L6l8meGCu47c4S1yct5y9JvnwlUxk3d8MAbm4hSBKJPGEYIjuwgu/5SGKDT2E012J7 T6I+oBl1DzeQhp3xC5entI3jxNtoPYMUNj+XrmV7GIZ3sbydJZqNL1TzaMFRZd5ES6Dl lu5jN6ISdGOTFDRQJWbRl7GVNqTNSdYtqykilVqlztGKnUr7x2OqrAytj4wlES5XIyea OVdWxu+F09iQPdfJMzeAqj+XRHPy5HJybMY2agTTHFzq1pQ0vxf3tw/LRTRmyaXOEjl3 82MyS+ExIs/JPorfbKY8OTCJ+qfAlqjSKtpG46s4EE9zi9RnGz6wZWXVqnC/0uDN+Ehb uCkw== X-Gm-Message-State: ABuFfojK+TCu/RqN0iY5ZV2EPZgLE3Ppl2I4/eJfq/ChdZNzFznjOcNT x0PDTF37qJAz0PR6qasAyam5JQ== X-Received: by 2002:adf:e808:: with SMTP id o8-v6mr5337755wrm.269.1538673658645; Thu, 04 Oct 2018 10:20:58 -0700 (PDT) Received: from brauner.io ([2a02:8070:8895:9700:2824:7b8c:14f1:9980]) by smtp.gmail.com with ESMTPSA id i7-v6sm5038814wrb.30.2018.10.04.10.20.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Oct 2018 10:20:57 -0700 (PDT) Date: Thu, 4 Oct 2018 19:20:51 +0200 From: Christian Brauner To: Aleksa Sarai Cc: Jann Horn , Al Viro , "Eric W. Biederman" , Andy Lutomirski , jlayton@kernel.org, Bruce Fields , Arnd Bergmann , shuah@kernel.org, David Howells , Tycho Andersen , kernel list , linux-fsdevel@vger.kernel.org, linux-arch , linux-kselftest@vger.kernel.org, dev@opencontainers.org, containers@lists.linux-foundation.org Subject: Re: [PATCH 1/3] namei: implement O_BENEATH-style AT_* flags Message-ID: <20181004172050.wja5nwjkfa3jjmzw@brauner.io> References: <20180929103453.12025-1-cyphar@cyphar.com> <20180929103453.12025-2-cyphar@cyphar.com> <20181001130038.s5ztphs3pl2zt3ut@brauner.io> <20181001160431.emb6b2hf32b754cl@ryuk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181001160431.emb6b2hf32b754cl@ryuk> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 02, 2018 at 02:04:31AM +1000, Aleksa Sarai wrote: > On 2018-10-01, Christian Brauner wrote: > > On Mon, Oct 01, 2018 at 02:28:03PM +0200, Jann Horn wrote: > > > On Sat, Sep 29, 2018 at 4:28 PM Aleksa Sarai wrote: > > > > * AT_BENEATH: Disallow ".." or absolute paths (either in the path or > > > > found during symlink resolution) to escape the starting point of name > > > > resolution, though ".." is permitted in cases like "foo/../bar". > > > > Relative symlinks are still allowed (as long as they don't escape the > > > > starting point). > > > > > > As I said on the other thread, I would strongly prefer an API that > > > behaves along the lines of David Drysdale's old patch > > > https://lore.kernel.org/lkml/1439458366-8223-2-git-send-email-drysdale@google.com/ > > > : Forbid any use of "..". This would also be more straightforward to > > > implement safely. If that doesn't work for you, I would like it if you > > > could at least make that an option. I would like it if this API could > > > mitigate straightforward directory traversal bugs such as > > > https://bugs.chromium.org/p/project-zero/issues/detail?id=1583, where > > > a confused deputy attempts to access a path like > > > "/mnt/media_rw/../../data" while intending to access a directory under > > > "/mnt/media_rw". > > > > Oh, the semantics for this changed in this patchset, hah. I was still on > > vacation so didn't get to look at it before it was sent out. From prior > > discussion I remember that the original intention actual was what you > > argue for. And the patchset should be as tight as possible. Having > > special cases where ".." is allowed just sounds like an invitation for > > userspace to get it wrong. > > Aleksa, did you have a specific use-case in mind that made you change > > this or was it already present in an earlier iteration of the patchset > > by someone else? > > Al's original patchset allowed "..". A quick survey of my machine shows > that there are 100k symlinks that contain ".." (~37% of all symlinks on > my machine). This indicates to me that you would be restricting a large > amount of reasonable resolutions because of this restriction. > > I posted a proposed way to protect against ".." shenanigans. If it's > turns out this is not possible, I'm okay with disallowing ".." (assuming > Al is also okay with that). Sounds acceptable to me.