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
841#define __NR_mseal 462841#define __NR_mseal 462
842__SYSCALL(__NR_mseal, sys_mseal)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#undef __NR_syscalls853#undef __NR_syscalls
845#define __NR_syscalls 463854#define __NR_syscalls 467
846 855
847/*856/*
848 * 32 bit systems traditionally used different857 * 32 bit systems traditionally used different
include/uapi/linux/xattr.h+7−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
11*/11*/
12 12
13#include <linux/libc-compat.h>13#include <linux/libc-compat.h>
14#include <linux/types.h>
14 15
15#ifndef _UAPI_LINUX_XATTR_H16#ifndef _UAPI_LINUX_XATTR_H
16#define _UAPI_LINUX_XATTR_H17#define _UAPI_LINUX_XATTR_H
@@ -20,6 +21,12 @@ · 3 unmodified lines
20 21
21#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */22#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
22#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */23#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
24
25struct xattr_args {
26 __aligned_u64 __user value;
27 __u32 size;
28 __u32 flags;
29};
23#endif30#endif
24 31
25/* Namespaces */32/* 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