Skip to content

LSM: Three basic syscalls

Casey Schaufler linux-api linux-fsdevel linux-integrity linux-security-module lkml selinux 15 versions – NAK

Status from this message: Nacked-by: Tetsuo Handa <[email protected]>

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v15 Latest11 patches 58 repliesNAK
  2. v1411 patches 10 repliesSuperseded
  3. v1311 patches 26 repliesSuperseded
Earlier versions · 12
VersionPostedPatchesRepliesStatus
v1211 patches20 repliesSuperseded
v1111 patches4 repliesSuperseded
v10 posting 2/211 patches11 repliesSuperseded
v10 posting 1/210 of 11 patches0 repliesSuperseded
v911 patches14 repliesSuperseded
v811 patches6 repliesSuperseded
v711 patches32 repliesSuperseded
v611 patches13 repliesSuperseded
v58 patches21 repliesSuperseded
v48 patches0 repliesSuperseded
v39 patches10 repliesSuperseded
v18 patches1 replySuperseded

Patches in v15

#Subject and filesSizeRepliesApplied
1/11LSM: Identify modules by more than nameDocumentation/userspace-api/index.rst MAINTAINERS include/linux/lsm_hooks.h +17 more+161 -2116 replies
2/11LSM: Maintain a table of LSM attribute datainclude/linux/security.h security/security.c+39 -00 replies
3/11proc: Use lsmids instead of lsm names for attrsfs/proc/base.c fs/proc/internal.h include/linux/security.h +1 more+28 -290 replies
4/11LSM: syscalls for current process attributesDocumentation/userspace-api/lsm.rst include/linux/lsm_hook_defs.h include/linux/lsm_hooks.h +7 more+347 -06 replies
5/11LSM: Create lsm_list_modules system callDocumentation/userspace-api/lsm.rst include/linux/syscalls.h kernel/sys_ni.c +1 more+44 -013 replies
6/11LSM: wireup Linux Security Module syscallsarch/alpha/kernel/syscalls/syscall.tbl arch/arm/tools/syscall.tbl arch/arm64/include/asm/unistd.h +20 more+75 -21 reply
7/11LSM: Helpers for attribute names and filling lsm_ctxinclude/linux/security.h security/lsm_syscalls.c security/security.c+79 -01 reply
8/11Smack: implement setselfattr and getselfattr hookssecurity/smack/smack_lsm.c+90 -53 replies
9/11AppArmor: Add selfattr hookssecurity/apparmor/include/procattr.h security/apparmor/lsm.c security/apparmor/procattr.c+92 -110 replies
10/11SELinux: Add selfattr hookssecurity/selinux/hooks.c+107 -270 replies
11/11LSM: selftests for Linux Security Module syscallsMAINTAINERS tools/testing/selftests/Makefile tools/testing/selftests/lsm/.gitignore +7 more+634 -01 reply

Reviews trailers per patch

10 of 11 patches have a Reviewed-by or Acked-by.

PatchKees CookSerge HallynMickael SalaunJohn JohansenGeert UytterhoevenArnd BergmannTetsuo Handa
1/11R-b R-b R-b R-b Nacked-by
2/11R-b R-b R-b R-b
3/11R-b R-b R-b R-b
4/11R-b R-b R-b
5/11R-b R-b R-b R-b
6/11R-b R-b A-b A-b
7/11R-b R-b R-b
8/11R-b
9/11A-b
10/11
11/11R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v15 thread

Cover letter [PATCH v15 00/11] LSM: Three basic syscalls

Add three system calls for the Linux Security Module ABI.

lsm_get_self_attr() provides the security module specific attributes that have previously been visible in the /proc/self/attr directory. For each security module that uses the specified attribute on the current process the system call will return an LSM identifier and the value of the attribute. The LSM and attribute identifier values are defined in include/uapi/linux/lsm.h

LSM identifiers are simple integers and reflect the order in which the LSM was added to the mainline kernel. This is a convention, not a promise of the API. LSM identifiers below the value of 100 are reserved for unspecified future uses. That could include information about the security infrastructure itself, or about how multiple LSMs might interact with each other.

A new LSM hook security_getselfattr() is introduced to get the required information from the security modules. This is similar to the existing security_getprocattr() hook, but specifies the format in which string data is returned and requires the module to put the information into a userspace destination.

lsm_set_self_attr() changes the specified LSM attribute. Only one attribute can be changed at a time, and then only if the specified security module allows the change.

A new LSM hook security_setselfattr() is introduced to set the required information in the security modules. This is similar to the existing security_setprocattr() hook, but specifies the format in which string data is presented and requires the module to get the information from a userspace destination.

lsm_list_modules() provides the LSM identifiers, in order, of the security modules that are active on the system. This has been available in the securityfs file /sys/kernel/security/lsm.

Patch 0001 changes the LSM registration from passing the name of the module to passing a lsm_id structure that contains the name of the module, an LSM identifier number and an attribute identifier.
Patch 0002 adds the registered lsm_ids to a table.
Patch 0003 changes security_[gs]etprocattr() to use LSM IDs instead of LSM names.
Patch 0004 implements lsm_get_self_attr() and lsm_set_self_attr(). New LSM hooks security_getselfattr() and security_setselfattr() are defined.
Patch 0005 implements lsm_list_modules().
Patch 0006 wires up the syscalls.
Patch 0007 implements helper functions to make it easier for security modules to use lsm_ctx structures.
Patch 0008 provides the Smack implementation for [gs]etselfattr(). Patch 0009 provides the AppArmor implementation for [gs]etselfattr(). Patch 0010 provides the SELinux implementation for [gs]etselfattr(). Patch 0011 implements selftests for the three new syscalls.

https://github.com/cschaufler/lsm-stacking.git#syscalls-6.5-rc7-v14

v15: Rebased on 6.6-rc1.
Adopt suggested improvements to security_getprocattr, making the code easier to read.
Squash a code fix from 0011 to 0004.
v14: Make the handling of LSM_FLAG_SINGLE easier to understand.
Tighten the comments and documentation.
Better use of const, static, and __ro_after_init. Add selftests for LSM_FLAG_SINGLE cases.
v13: Change the setselfattr code to do a single user copy.
Make the self tests more robust.
Improve use of const.
Change syscall numbers to reflect upstream additions.
v12: Repair a registration time overflow check.
v11: Remove redundent alignment code
Improve a few comments.
Use LSM_ATTR_UNDEF in place of 0 in a few places. Correct a return of -EINVAL to -E2BIG.
v10: Correct use of __user.
Improve a few comments.
Revert unnecessary changes in module initialization.
v9: Support a flag LSM_FLAG_SINGLE in lsm_get_self_attr() that
instructs the call to provide only the attribute for the LSM identified in the referenced lsm_ctx structure.
Fix a typing error.
Change some coding style.
v8: Allow an LSM to provide more than one instance of an attribute,
even though none of the existing modules do so.
Pad the data returned by lsm_get_self_attr() to the size of the struct lsm_ctx.
Change some displeasing varilable names.
v7: Pass the attribute desired to lsm_[gs]et_self_attr in its own
parameter rather than encoding it in the flags. Change the flags parameters to u32.
Don't shortcut out of calling LSM specific code in the infrastructure, let the LSM report that doesn't support an attribute instead. With that it is not necessary to maintain a set of supported attributes in the lsm_id structure. Fix a typing error.
v6: Switch from reusing security_[gs]procattr() to using new
security_[gs]selfattr() hooks. Use explicit sized data types in the lsm_ctx structure.

v5: Correct syscall parameter data types.

v4: Restore "reserved" LSM ID values. Add explaination.
Squash patches that introduce fields in lsm_id. Correct a wireup error.

v3: Add lsm_set_self_attr().
Rename lsm_self_attr() to lsm_get_self_attr(). Provide the values only for a specifed attribute in lsm_get_self_attr().
Add selftests for the three new syscalls. Correct some parameter checking.

v2: Use user-interface safe data types.
Remove "reserved" LSM ID values.
Improve kerneldoc comments
Include copyright dates
Use more descriptive name for LSM counter
Add documentation
Correct wireup errors

Casey Schaufler (11):
LSM: Identify modules by more than name
LSM: Maintain a table of LSM attribute data
proc: Use lsmids instead of lsm names for attrs
LSM: syscalls for current process attributes
LSM: Create lsm_list_modules system call
LSM: wireup Linux Security Module syscalls
LSM: Helpers for attribute names and filling lsm_ctx
Smack: implement setselfattr and getselfattr hooks
AppArmor: Add selfattr hooks
SELinux: Add selfattr hooks
LSM: selftests for Linux Security Module syscalls

 Documentation/userspace-api/index.rst         |   1 +
 Documentation/userspace-api/lsm.rst           |  73 +++++
 MAINTAINERS                                   |   2 +
 arch/alpha/kernel/syscalls/syscall.tbl        |   3 +
 arch/arm/tools/syscall.tbl                    |   3 +
 arch/arm64/include/asm/unistd.h               |   2 +-
 arch/arm64/include/asm/unistd32.h             |   6 +
 arch/ia64/kernel/syscalls/syscall.tbl         |   3 +
 arch/m68k/kernel/syscalls/syscall.tbl         |   3 +
 arch/microblaze/kernel/syscalls/syscall.tbl   |   3 +
 arch/mips/kernel/syscalls/syscall_n32.tbl     |   3 +
 arch/mips/kernel/syscalls/syscall_n64.tbl     |   3 +
 arch/mips/kernel/syscalls/syscall_o32.tbl     |   3 +
 arch/parisc/kernel/syscalls/syscall.tbl       |   3 +
 arch/powerpc/kernel/syscalls/syscall.tbl      |   3 +
 arch/s390/kernel/syscalls/syscall.tbl         |   3 +
 arch/sh/kernel/syscalls/syscall.tbl           |   3 +
 arch/sparc/kernel/syscalls/syscall.tbl        |   3 +
 arch/x86/entry/syscalls/syscall_32.tbl        |   3 +
 arch/x86/entry/syscalls/syscall_64.tbl        |   3 +
 arch/xtensa/kernel/syscalls/syscall.tbl       |   3 +
 fs/proc/base.c                                |  29 +-
 fs/proc/internal.h                            |   2 +-
 include/linux/lsm_hook_defs.h                 |   4 +
 include/linux/lsm_hooks.h                     |  17 +-
 include/linux/security.h                      |  46 ++-
 include/linux/syscalls.h                      |   6 +
 include/uapi/asm-generic/unistd.h             |   9 +-
 include/uapi/linux/lsm.h                      |  90 ++++++
 kernel/sys_ni.c                               |   3 +
 security/Makefile                             |   1 +
 security/apparmor/include/procattr.h          |   2 +-
 security/apparmor/lsm.c                       |  99 ++++++-
 security/apparmor/procattr.c                  |  10 +-
 security/bpf/hooks.c                          |   9 +-
 security/commoncap.c                          |   8 +-
 security/landlock/cred.c                      |   2 +-
 security/landlock/fs.c                        |   2 +-
 security/landlock/ptrace.c                    |   2 +-
 security/landlock/setup.c                     |   6 +
 security/landlock/setup.h                     |   1 +
 security/loadpin/loadpin.c                    |   9 +-
 security/lockdown/lockdown.c                  |   8 +-
 security/lsm_syscalls.c                       | 120 ++++++++
 security/safesetid/lsm.c                      |   9 +-
 security/security.c                           | 253 +++++++++++++++-
 security/selinux/hooks.c                      | 143 +++++++--
 security/smack/smack_lsm.c                    | 103 ++++++-
 security/tomoyo/tomoyo.c                      |   9 +-
 security/yama/yama_lsm.c                      |   8 +-
 .../arch/mips/entry/syscalls/syscall_n64.tbl  |   3 +
 .../arch/powerpc/entry/syscalls/syscall.tbl   |   3 +
 .../perf/arch/s390/entry/syscalls/syscall.tbl |   3 +
 .../arch/x86/entry/syscalls/syscall_64.tbl    |   3 +
 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/lsm/.gitignore        |   1 +
 tools/testing/selftests/lsm/Makefile          |  17 ++
 tools/testing/selftests/lsm/common.c          |  89 ++++++
 tools/testing/selftests/lsm/common.h          |  33 +++
 tools/testing/selftests/lsm/config            |   3 +
 .../selftests/lsm/lsm_get_self_attr_test.c    | 275 ++++++++++++++++++
 .../selftests/lsm/lsm_list_modules_test.c     | 140 +++++++++
 .../selftests/lsm/lsm_set_self_attr_test.c    |  74 +++++
 63 files changed, 1694 insertions(+), 93 deletions(-)
 create mode 100644 Documentation/userspace-api/lsm.rst
 create mode 100644 include/uapi/linux/lsm.h
 create mode 100644 security/lsm_syscalls.c
 create mode 100644 tools/testing/selftests/lsm/.gitignore
 create mode 100644 tools/testing/selftests/lsm/Makefile
 create mode 100644 tools/testing/selftests/lsm/common.c
 create mode 100644 tools/testing/selftests/lsm/common.h
 create mode 100644 tools/testing/selftests/lsm/config
 create mode 100644 tools/testing/selftests/lsm/lsm_get_self_attr_test.c
 create mode 100644 tools/testing/selftests/lsm/lsm_list_modules_test.c
 create mode 100644 tools/testing/selftests/lsm/lsm_set_self_attr_test.c
Signature · 1 line
2.41.0