[lkml]   [2014]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCHv2 man-pages 3/3] open.2: describe O_BENEATH flag
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.
+.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
+.BR openat (2)).
+If the
+.I pathname
+is absolute or contains a path component of "..", the
+.BR open ()
+fails with the error
+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
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
+flag was specified and the
+.I pathname
+was not beneath the relevant directory.
.I pathname
refers to a file on a read-only filesystem and write access was

 \ /
  Last update: 2014-11-04 11:21    [W:0.092 / U:4.596 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site