path: root/fs/open.c
diff options
authorAleksa Sarai <>2020-10-28 10:50:43 +1100
committerChristian Brauner <>2020-12-03 10:15:50 +0100
commit398840f8bb935d33c64df4ec4fed77a7d24c267d (patch)
tree0a5bb96cba43ad586043b0fd121eefc558444d80 /fs/open.c
parentb65054597872ce3aefbc6a666385eabdf9e288da (diff)
This was an oversight in the original implementation, as it makes no sense to specify both scoping flags to the same openat2(2) invocation (before this patch, the result of such an invocation was equivalent to RESOLVE_IN_ROOT being ignored). This is a userspace-visible ABI change, but the only user of openat2(2) at the moment is LXC which doesn't specify both flags and so no userspace programs will break as a result. Fixes: fddb5d430ad9 ("open: introduce openat2(2) syscall") Signed-off-by: Aleksa Sarai <> Acked-by: Christian Brauner <> Cc: <> # v5.6+ Link: Signed-off-by: Christian Brauner <>
Diffstat (limited to 'fs/open.c')
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/open.c b/fs/open.c
index 9af548fb841b..4d7537ae59df 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1010,6 +1010,10 @@ inline int build_open_flags(const struct open_how *how, struct open_flags *op)
if (how->resolve & ~VALID_RESOLVE_FLAGS)
return -EINVAL;
+ /* Scoping flags are mutually exclusive. */
+ if ((how->resolve & RESOLVE_BENEATH) && (how->resolve & RESOLVE_IN_ROOT))
+ return -EINVAL;
/* Deal with the mode. */
if (WILL_CREATE(flags)) {
if (how->mode & ~S_IALLUGO)