Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbaKCPUl (ORCPT ); Mon, 3 Nov 2014 10:20:41 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:38018 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbaKCPUk (ORCPT ); Mon, 3 Nov 2014 10:20:40 -0500 Date: Mon, 3 Nov 2014 15:20:36 +0000 From: Al Viro To: David Drysdale Cc: 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 , Andy Lutomirski , Paolo Bonzini , Paul Moore , Christoph Hellwig , "Eric W. Biederman" , linux-api@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH 1/3] fs: add O_BENEATH flag to openat(2) Message-ID: <20141103152036.GA7996@ZenIV.linux.org.uk> References: <1415015305-15494-1-git-send-email-drysdale@google.com> <1415015305-15494-2-git-send-email-drysdale@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1415015305-15494-2-git-send-email-drysdale@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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), WTF pass one bit out of nameidata->flags in a separate argument? 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. -- 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/