Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

openat2: reject RESOLVE_BENEATH|RESOLVE_IN_ROOT

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 <cyphar@cyphar.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: <stable@vger.kernel.org> # v5.6+
Link: https://lore.kernel.org/r/20201027235044.5240-2-cyphar@cyphar.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

authored by

Aleksa Sarai and committed by
Christian Brauner
398840f8 b6505459

+4
+4
fs/open.c
··· 1010 1010 if (how->resolve & ~VALID_RESOLVE_FLAGS) 1011 1011 return -EINVAL; 1012 1012 1013 + /* Scoping flags are mutually exclusive. */ 1014 + if ((how->resolve & RESOLVE_BENEATH) && (how->resolve & RESOLVE_IN_ROOT)) 1015 + return -EINVAL; 1016 + 1013 1017 /* Deal with the mode. */ 1014 1018 if (WILL_CREATE(flags)) { 1015 1019 if (how->mode & ~S_IALLUGO)