Add the four syscalls setxattrat(), getxattrat(), listxattrat() and removexattrat(). Those can be used to operate on extended attributes, especially security related ones, either relative to a pinned directory or on a file descriptor without read access, avoiding a /proc/<pid>/fd/<fd> detour, requiring a mounted procfs. One use case will be setfiles(8) setting SELinux file contexts ("security.selinux") without race conditions and without a file descriptor opened with read access requiring SELinux read permission. Use the do_{name}at() pattern from fs/open.c. Pass the value of the extended attribute, its length, and for setxattrat(2) the command (XATTR_CREATE or XATTR_REPLACE) via an added struct xattr_args to not exceed six syscall arguments and not merging the AT_* and XATTR_* flags. [AV: fixes by Christian Brauner folded in, the entire thing rebased on top of {filename,file}_...xattr() primitives, treatment of empty pathnames regularized. As the result, AT_EMPTY_PATH+NULL handling is cheap, so f...(2) can use it]
Showing the changes to include/uapi (2 of 23 files). Show all
Unified · Split
| @@ -841,8 +841,17 @@ __SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules) · 840 unmodified lines | ||
| 841 | 841 | #define __NR_mseal 462 |
| 842 | 842 | __SYSCALL(__NR_mseal, sys_mseal) |
| 843 | 843 | |
| 844 | +#define __NR_setxattrat 463 | |
| 845 | +__SYSCALL(__NR_setxattrat, sys_setxattrat) | |
| 846 | +#define __NR_getxattrat 464 | |
| 847 | +__SYSCALL(__NR_getxattrat, sys_getxattrat) | |
| 848 | +#define __NR_listxattrat 465 | |
| 849 | +__SYSCALL(__NR_listxattrat, sys_listxattrat) | |
| 850 | +#define __NR_removexattrat 466 | |
| 851 | +__SYSCALL(__NR_removexattrat, sys_removexattrat) | |
| 852 | + | |
| 844 | 853 | #undef __NR_syscalls |
| 845 | −#define __NR_syscalls 463 | |
| 854 | +#define __NR_syscalls 467 | |
| 846 | 855 | |
| 847 | 856 | /* |
| 848 | 857 | * 32 bit systems traditionally used different |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | #include <linux/libc-compat.h> |
| 14 | +#include <linux/types.h> | |
| 14 | 15 | |
| 15 | 16 | #ifndef _UAPI_LINUX_XATTR_H |
| 16 | 17 | #define _UAPI_LINUX_XATTR_H |
| @@ -20,6 +21,12 @@ · 3 unmodified lines | ||
| 20 | 21 | |
| 21 | 22 | #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ |
| 22 | 23 | #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ |
| 24 | + | |
| 25 | +struct xattr_args { | |
| 26 | + __aligned_u64 __user value; | |
| 27 | + __u32 size; | |
| 28 | + __u32 flags; | |
| 29 | +}; | |
| 23 | 30 | #endif |
| 24 | 31 | |
| 25 | 32 | /* Namespaces */ |