Skip to content

Commit 6140be9

Browse files
cgzonesAl Viro
authored andcommitted
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] Signed-off-by: Christian Göttsche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Arnd Bergmann <[email protected]> Reviewed-by: Christian Brauner <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] [brauner: slight tweaks] Signed-off-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 22a4d19 commit 6140be9

File tree

23 files changed

+268
-86
lines changed

23 files changed

+268
-86
lines changed

arch/alpha/kernel/syscalls/syscall.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,7 @@
502502
570 common lsm_set_self_attr sys_lsm_set_self_attr
503503
571 common lsm_list_modules sys_lsm_list_modules
504504
572 common mseal sys_mseal
505+
573 common setxattrat sys_setxattrat
506+
574 common getxattrat sys_getxattrat
507+
575 common listxattrat sys_listxattrat
508+
576 common removexattrat sys_removexattrat

arch/arm/tools/syscall.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,7 @@
477477
460 common lsm_set_self_attr sys_lsm_set_self_attr
478478
461 common lsm_list_modules sys_lsm_list_modules
479479
462 common mseal sys_mseal
480+
463 common setxattrat sys_setxattrat
481+
464 common getxattrat sys_getxattrat
482+
465 common listxattrat sys_listxattrat
483+
466 common removexattrat sys_removexattrat

arch/arm64/tools/syscall_32.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,7 @@
474474
460 common lsm_set_self_attr sys_lsm_set_self_attr
475475
461 common lsm_list_modules sys_lsm_list_modules
476476
462 common mseal sys_mseal
477+
463 common setxattrat sys_setxattrat
478+
464 common getxattrat sys_getxattrat
479+
465 common listxattrat sys_listxattrat
480+
466 common removexattrat sys_removexattrat

arch/m68k/kernel/syscalls/syscall.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,7 @@
462462
460 common lsm_set_self_attr sys_lsm_set_self_attr
463463
461 common lsm_list_modules sys_lsm_list_modules
464464
462 common mseal sys_mseal
465+
463 common setxattrat sys_setxattrat
466+
464 common getxattrat sys_getxattrat
467+
465 common listxattrat sys_listxattrat
468+
466 common removexattrat sys_removexattrat

arch/microblaze/kernel/syscalls/syscall.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,7 @@
468468
460 common lsm_set_self_attr sys_lsm_set_self_attr
469469
461 common lsm_list_modules sys_lsm_list_modules
470470
462 common mseal sys_mseal
471+
463 common setxattrat sys_setxattrat
472+
464 common getxattrat sys_getxattrat
473+
465 common listxattrat sys_listxattrat
474+
466 common removexattrat sys_removexattrat

arch/mips/kernel/syscalls/syscall_n32.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,7 @@
401401
460 n32 lsm_set_self_attr sys_lsm_set_self_attr
402402
461 n32 lsm_list_modules sys_lsm_list_modules
403403
462 n32 mseal sys_mseal
404+
463 n32 setxattrat sys_setxattrat
405+
464 n32 getxattrat sys_getxattrat
406+
465 n32 listxattrat sys_listxattrat
407+
466 n32 removexattrat sys_removexattrat

arch/mips/kernel/syscalls/syscall_n64.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,7 @@
377377
460 n64 lsm_set_self_attr sys_lsm_set_self_attr
378378
461 n64 lsm_list_modules sys_lsm_list_modules
379379
462 n64 mseal sys_mseal
380+
463 n64 setxattrat sys_setxattrat
381+
464 n64 getxattrat sys_getxattrat
382+
465 n64 listxattrat sys_listxattrat
383+
466 n64 removexattrat sys_removexattrat

arch/mips/kernel/syscalls/syscall_o32.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,7 @@
450450
460 o32 lsm_set_self_attr sys_lsm_set_self_attr
451451
461 o32 lsm_list_modules sys_lsm_list_modules
452452
462 o32 mseal sys_mseal
453+
463 o32 setxattrat sys_setxattrat
454+
464 o32 getxattrat sys_getxattrat
455+
465 o32 listxattrat sys_listxattrat
456+
466 o32 removexattrat sys_removexattrat

arch/parisc/kernel/syscalls/syscall.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,7 @@
461461
460 common lsm_set_self_attr sys_lsm_set_self_attr
462462
461 common lsm_list_modules sys_lsm_list_modules
463463
462 common mseal sys_mseal
464+
463 common setxattrat sys_setxattrat
465+
464 common getxattrat sys_getxattrat
466+
465 common listxattrat sys_listxattrat
467+
466 common removexattrat sys_removexattrat

arch/powerpc/kernel/syscalls/syscall.tbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,7 @@
553553
460 common lsm_set_self_attr sys_lsm_set_self_attr
554554
461 common lsm_list_modules sys_lsm_list_modules
555555
462 common mseal sys_mseal
556+
463 common setxattrat sys_setxattrat
557+
464 common getxattrat sys_getxattrat
558+
465 common listxattrat sys_listxattrat
559+
466 common removexattrat sys_removexattrat

0 commit comments

Comments
 (0)