This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v18 11/13] open: introduce openat2(2) syscall
- From: Florian Weimer <fweimer at redhat dot com>
- To: Aleksa Sarai <cyphar at cyphar dot com>
- Cc: Al Viro <viro at zeniv dot linux dot org dot uk>, Jeff Layton <jlayton at kernel dot org>, "J. Bruce Fields" <bfields at fieldses dot org>, Arnd Bergmann <arnd at arndb dot de>, David Howells <dhowells at redhat dot com>, Shuah Khan <shuah at kernel dot org>, Shuah Khan <skhan at linuxfoundation dot org>, Ingo Molnar <mingo at redhat dot com>, Peter Zijlstra <peterz at infradead dot org>, Alexei Starovoitov <ast at kernel dot org>, Daniel Borkmann <daniel at iogearbox dot net>, Martin KaFai Lau <kafai at fb dot com>, Song Liu <songliubraving at fb dot com>, Yonghong Song <yhs at fb dot com>, Andrii Nakryiko <andriin at fb dot com>, Jonathan Corbet <corbet at lwn dot net>, linux-ia64 at vger dot kernel dot org, linux-doc at vger dot kernel dot org, Alexander Shishkin <alexander dot shishkin at linux dot intel dot com>, Rasmus Villemoes <linux at rasmusvillemoes dot dk>, linux-kernel at vger dot kernel dot org, linux-kselftest at vger dot kernel dot org, sparclinux at vger dot kernel dot org, linux-api at vger dot kernel dot org, Jiri Olsa <jolsa at redhat dot com>, linux-arch at vger dot kernel dot org, linux-s390 at vger dot kernel dot org, linux-sh at vger dot kernel dot org, David Drysdale <dr ysdale at google dot com>, linux-arm-kernel at lists dot infradead dot org, linux-mips at vger dot kernel dot org, linux-xtensa at linux-xtensa dot org, Kees Cook <keescook at chromium dot org>, Jann Horn <jannh at google dot com>, linuxppc-dev at lists dot ozlabs dot org, dev at opencontainers dot org, Andy Lutomirski <luto at kernel dot org>, Namhyung Kim <namhyung at kernel dot org>, Andrew Morton <akpm at linux-foundation dot org>, libc-alpha at sourceware dot org, linux-parisc at vger dot kernel dot org, linux-m68k at lists dot linux-m68k dot org, netdev at vger dot kernel dot org, Chanho Min <chanho dot min at lge dot com>, Oleg Nesterov <oleg at redhat dot com>, Eric Biederman <ebiederm at xmission dot com>, linux-alpha at vger dot kernel dot org, linux-fsdevel at vger dot kernel dot org, bpf at vger dot kernel dot org, Linus Torvalds <torvalds at linux-foundation dot org>, containers at lists dot linux-foundation dot org
- Date: Mon, 16 Dec 2019 20:20:17 +0100
- Subject: Re: [PATCH v18 11/13] open: introduce openat2(2) syscall
- References: <20191206141338.23338-1-cyphar@cyphar.com> <20191206141338.23338-12-cyphar@cyphar.com>
* Aleksa Sarai:
> diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
> index 1d338357df8a..58c3a0e543c6 100644
> --- a/include/uapi/linux/fcntl.h
> +++ b/include/uapi/linux/fcntl.h
> @@ -93,5 +93,40 @@
>
> #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
>
> +/*
> + * Arguments for how openat2(2) should open the target path. If @resolve is
> + * zero, then openat2(2) operates very similarly to openat(2).
> + *
> + * However, unlike openat(2), unknown bits in @flags result in -EINVAL rather
> + * than being silently ignored. @mode must be zero unless one of {O_CREAT,
> + * O_TMPFILE} are set.
> + *
> + * @flags: O_* flags.
> + * @mode: O_CREAT/O_TMPFILE file mode.
> + * @resolve: RESOLVE_* flags.
> + */
> +struct open_how {
> + __aligned_u64 flags;
> + __u16 mode;
> + __u16 __padding[3]; /* must be zeroed */
> + __aligned_u64 resolve;
> +};
> +
> +#define OPEN_HOW_SIZE_VER0 24 /* sizeof first published struct */
> +#define OPEN_HOW_SIZE_LATEST OPEN_HOW_SIZE_VER0
> +
> +/* how->resolve flags for openat2(2). */
> +#define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings
> + (includes bind-mounts). */
> +#define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style
> + "magic-links". */
> +#define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks
> + (implies OEXT_NO_MAGICLINKS) */
> +#define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like
> + "..", symlinks, and absolute
> + paths which escape the dirfd. */
> +#define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".."
> + be scoped inside the dirfd
> + (similar to chroot(2)). */
>
> #endif /* _UAPI_LINUX_FCNTL_H */
Would it be possible to move these to a new UAPI header?
In glibc, we currently do not #include <linux/fcntl.h>. We need some of
the AT_* constants in POSIX mode, and the header is not necessarily
namespace-clean. If there was a separate header for openat2 support, we
could use that easily, and we would only have to maintain the baseline
definitions (which never change).
Thanks,
Florian