History

fs/xattr: add *at family syscalls

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]

Christian Göttsche committed 2 years ago

Commit 6140be91 parent 22a4d1923 files · +268 −86Browse files

Showing the changes to include/uapi (2 of 23 files). Show all

Unified · Split

2 files
  1. include/uapi/asm-generic/unistd.h +10 −1
  2. include/uapi/linux/xattr.h +7 −0
include/uapi/asm-generic/unistd.h+10−1
@@ -841,8 +841,17 @@ __SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules) · 840 unmodified lines
841841 #define __NR_mseal 462
842842 __SYSCALL(__NR_mseal, sys_mseal)
843843
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+
844853 #undef __NR_syscalls
845−#define __NR_syscalls 463
854+#define __NR_syscalls 467
846855
847856 /*
848857 * 32 bit systems traditionally used different
include/uapi/linux/xattr.h+7−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 */
1212
1313 #include <linux/libc-compat.h>
14+#include <linux/types.h>
1415
1516 #ifndef _UAPI_LINUX_XATTR_H
1617 #define _UAPI_LINUX_XATTR_H
@@ -20,6 +21,12 @@ · 3 unmodified lines
2021
2122 #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
2223 #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+};
2330 #endif
2431
2532 /* Namespaces */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t