Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3225201imu; Sat, 24 Nov 2018 00:31:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xmfar5YU61Jkr9VexhQxtOifZ7TT2BcEQ07v1I6AdSnd0TIeH+5WT7FupNZF4rFwzNTdiH X-Received: by 2002:a63:ee4c:: with SMTP id n12mr16624612pgk.21.1543048286713; Sat, 24 Nov 2018 00:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048286; cv=none; d=google.com; s=arc-20160816; b=yIEDaL7KnSU/ZPDhO+y+gVPY4kJ+Sz51JPEhZqqUaxM4R9uu+nY/jrVjxIfuAGcky+ ZOypSUJi3yAqU4IoV0n56IDpurncOhiVER0INlyAuZsFdeZ8HIVMma5Y4MD7AgSAb+Ia yoIK8OwtOS/0ibcn3ySWLGp2CJ46sguR6Jw8UU0TKUgoHHYmuAeWIKGkOfsh4m+YImRM qpa+ZdzfEUYJXtC2QboBVVIGR3e4C0QDqurEfn/nzXzsir9PpqCXbiFPv7FSlils10M/ wL7Ql0zWd30/+6k9HeLjw3MX9VqrR2eUPikjOvHKBWVkChctSKVMcX2f41S9ZtX+NpZ/ p7cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=Ai6IFvBIwlH7b9WXeY5axUXHljbtyvHPo9WdC4YAII0=; b=YBuWQgi1HQTVarhlAEHAW5EPCPpqyrCoofuGWjvcb2m/e46PtWelGFsuKAMJL1T0u3 dyh1O58LCATJV0uizenkkkj0dlmdzzpkVljfyT3x80txzZJ7NG10+LnA2ISrr7+Npzsx qd5FUd/jtOlFb5EKvE/Sv+tG/Ln5xtGXHs+VKf5AWYIv6V1lxHB4ilW147Mu50H9Qq7M dGEIG9UuQLEnvwpFEdHwr2m5Lllecvvd5nThO5tLZOR4WpWPXwR7w/XoWQfV9i3Udbw9 U1zhcm4iEuAo5RBq+anHbsMzhvLZqj4aRAUth50NVDORH1NiBwTdmj1LdEot3aCuE/4m n0fw== 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 j24si54894212pgh.362.2018.11.24.00.31.12; Sat, 24 Nov 2018 00:31:26 -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 S2504182AbeKWXEY (ORCPT + 99 others); Fri, 23 Nov 2018 18:04:24 -0500 Received: from nov-007-i650.relay.mailchannels.net ([46.232.183.204]:34405 "EHLO nov-007-i650.relay.mailchannels.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387923AbeKWXEY (ORCPT ); Fri, 23 Nov 2018 18:04:24 -0500 X-Greylist: delayed 593 seconds by postgrey-1.27 at vger.kernel.org; Fri, 23 Nov 2018 18:04:20 EST X-Sender-Id: novatrend|x-authuser|juerg@bitron.ch Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 04BAEBE050F; Fri, 23 Nov 2018 12:10:27 +0000 (UTC) Received: from srv17.tophost.ch (swiss-ingress-1.ch.mailchannels.com [46.232.183.5]) by relay.mailchannels.net (Postfix) with ESMTPA id 4A4B5BE00D9; Fri, 23 Nov 2018 12:10:19 +0000 (UTC) X-Sender-Id: novatrend|x-authuser|juerg@bitron.ch Received: from srv17.tophost.ch (srv17.tophost.ch [193.33.128.141]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.15.2); Fri, 23 Nov 2018 12:10:27 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: novatrend|x-authuser|juerg@bitron.ch X-MailChannels-Auth-Id: novatrend X-Share-Drop: 059264ac1b1d5ec2_1542975026764_388681693 X-MC-Loop-Signature: 1542975026764:3636178841 X-MC-Ingress-Time: 1542975026763 Received: from [80.219.231.201] (port=46298 helo=jzen.bitron.ch) by srv17.tophost.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gQAHq-003RuN-0I; Fri, 23 Nov 2018 13:10:18 +0100 Message-ID: <1ce83cdf6e3168350b69f98f08aaa202bbaa682d.camel@bitron.ch> Subject: Re: [PATCH v4 2/4] namei: O_BENEATH-style path resolution flags From: =?ISO-8859-1?Q?J=FCrg?= Billeter To: Aleksa Sarai , Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells Cc: Eric Biederman , Christian Brauner , linux-api@vger.kernel.org, Andy Lutomirski , Jann Horn , David Drysdale , Aleksa Sarai , containers@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Date: Fri, 23 Nov 2018 13:10:17 +0100 In-Reply-To: <20181112142654.341-3-cyphar@cyphar.com> References: <20181112142654.341-1-cyphar@cyphar.com> <20181112142654.341-3-cyphar@cyphar.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-AuthUser: juerg@bitron.ch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Aleksa, On Tue, 2018-11-13 at 01:26 +1100, Aleksa Sarai wrote: > * O_BENEATH: Disallow "escapes" from the starting point of the > filesystem tree during resolution (you must stay "beneath" the > starting point at all times). Currently this is done by disallowing > ".." and absolute paths (either in the given path or found during > symlink resolution) entirely, as well as all "magic link" jumping. With open_tree(2) and OPEN_TREE_CLONE, will O_BENEATH still be necessary? As I understand it, O_BENEATH could be replaced by a much simpler flag that only disallows absolute paths (incl. absolute symlinks). And it would have the benefit that you can actually pass the tree/directory fd to another process and escaping would not be possible even if that other process doesn't use O_BENEATH (after calling mount_setattr(2) to make sure it's locked down). This approach would also make it easy to restrict writes via a cloned tree/directory fd by marking it read-only via mount_setattr(2) (and locking down the read-only flag). This would again be especially useful when passing tree/directory fds across processes, or for voluntary self-lockdown within a process for robustness against security bugs. This wouldn't affect any of the other flags in this patch. And for full equivalence to O_BENEATH you'd have to use O_NOMAGICLINKS in addition to O_NOABSOLUTE, or whatever that new flag would be called. Or is OPEN_TREE_CLONE too expensive for this use case? Or is there anything else I'm missing? Jürg