Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753438AbaKDKBH (ORCPT ); Tue, 4 Nov 2014 05:01:07 -0500 Received: from mail-ee0-f73.google.com ([74.125.83.73]:56204 "EHLO mail-ee0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752628AbaKDKBA (ORCPT ); Tue, 4 Nov 2014 05:01:00 -0500 X-Greylist: delayed 358 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Nov 2014 05:00:59 EST From: David Drysdale To: linux-kernel@vger.kernel.org, Alexander Viro , Kees Cook , "Eric W. Biederman" Cc: 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 , linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, David Drysdale Subject: [PATCHv2 man-pages 3/3] open.2: describe O_BENEATH flag Date: Tue, 4 Nov 2014 09:54:44 +0000 Message-Id: <1415094884-18349-4-git-send-email-drysdale@google.com> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1415094884-18349-1-git-send-email-drysdale@google.com> References: <1415094884-18349-1-git-send-email-drysdale@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: David Drysdale --- man2/open.2 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/man2/open.2 b/man2/open.2 index abc3c35b8b3a..f06edc4aa843 100644 --- a/man2/open.2 +++ b/man2/open.2 @@ -716,6 +716,31 @@ XFS support was added .\" commit ab29743117f9f4c22ac44c13c1647fb24fb2bafe in Linux 3.15. .TP +.B O_BENEATH " (since Linux 3.??)" +Ensure that the +.I pathname +is beneath the current working directory (for +.BR open (2)) +or the +.I dirfd +(for +.BR openat (2)). +If the +.I pathname +is absolute or contains a path component of "..", the +.BR open () +fails with the error +.BR EPERM. +This occurs even if ".." path component would not actually +escape the original directory; for example, a +.I pathname +of "subdir/../filename" would be rejected. +Path components that are symbolic links to absolute paths, or that are +relative paths containing a ".." component, will also cause the +.BR open () +operation to fail with the error +.BR EPERM. +.TP .B O_TRUNC If the file already exists and is a regular file and the access mode allows writing (i.e., is @@ -976,6 +1001,13 @@ flag was specified, but the effective user ID of the caller did not match the owner of the file and the caller was not privileged .RB ( CAP_FOWNER ). .TP +.B EPERM +The +.B O_BENEATH +flag was specified and the +.I pathname +was not beneath the relevant directory. +.TP .B EROFS .I pathname refers to a file on a read-only filesystem and write access was -- 2.1.0.rc2.206.gedb03e5 -- 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/