Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbaKCRiB (ORCPT ); Mon, 3 Nov 2014 12:38:01 -0500 Received: from mail-qc0-f170.google.com ([209.85.216.170]:55400 "EHLO mail-qc0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752036AbaKCRh7 (ORCPT ); Mon, 3 Nov 2014 12:37:59 -0500 MIME-Version: 1.0 In-Reply-To: References: <1415015305-15494-1-git-send-email-drysdale@google.com> <1415015305-15494-2-git-send-email-drysdale@google.com> <20141103152036.GA7996@ZenIV.linux.org.uk> From: David Drysdale Date: Mon, 3 Nov 2014 17:37:37 +0000 Message-ID: Subject: Re: [PATCH 1/3] fs: add O_BENEATH flag to openat(2) To: Andy Lutomirski Cc: Al Viro , "linux-kernel@vger.kernel.org" , Kees Cook , Greg Kroah-Hartman , Meredydd Luff , Will Drewry , Jorge Lucangeli Obes , Ricky Zhou , Lee Campbell , Julien Tinnes , Mike Depinet , James Morris , Paolo Bonzini , Paul Moore , Christoph Hellwig , "Eric W. Biederman" , Linux API , LSM List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 3, 2014 at 3:42 PM, Andy Lutomirski wrote: > On Mon, Nov 3, 2014 at 7:20 AM, Al Viro wrote: >> On Mon, Nov 03, 2014 at 11:48:23AM +0000, David Drysdale wrote: >>> Add a new O_BENEATH flag for openat(2) which restricts the >>> provided path, rejecting (with -EACCES) paths that are not beneath >>> the provided dfd. In particular, reject: >>> - paths that contain .. components >>> - paths that begin with / >>> - symlinks that have paths as above. >> >> Yecch... The degree of usefulness aside (and I'm not convinced that it >> is non-zero), > > This is extremely useful in conjunction with seccomp. Yes, that was my understanding of how the Chrome[OS] folk wanted to use it. >> WTF pass one bit out of nameidata->flags in a separate argument? I'll shift to using nd->flags; not sure what I was thinking of there. (It *might* have made more sense in the full patchset this was extracted from but it certainly doesn't look sensible in this narrower context.) >> Through the mutual recursion, no less... And then you are not even attempting >> to detect symlinks that are not followed by interpretation of _any_ pathname. > > How many symlinks like that are there? Is there anything except > nd_jump_link users? All of those are in /proc. Arguably O_BENEATH > should prevent traversal of all of those links. > > --Andy On a quick search, the 2 users of nd_jump_link (namely proc_pid_follow_link and proc_ns_follow_link) seem to be the only implementations of inode_operations->follow_link that don't just call nd_set_link(). So disallowing that for O_BENEATH might give sensible behaviour. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/