Skip to content

Commit 063a7ce

Browse files
committed
Merge tag 'lsm-pr-20240105' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm
Pull security module updates from Paul Moore: - Add three new syscalls: lsm_list_modules(), lsm_get_self_attr(), and lsm_set_self_attr(). The first syscall simply lists the LSMs enabled, while the second and third get and set the current process' LSM attributes. Yes, these syscalls may provide similar functionality to what can be found under /proc or /sys, but they were designed to support multiple, simultaneaous (stacked) LSMs from the start as opposed to the current /proc based solutions which were created at a time when only one LSM was allowed to be active at a given time. We have spent considerable time discussing ways to extend the existing /proc interfaces to support multiple, simultaneaous LSMs and even our best ideas have been far too ugly to support as a kernel API; after +20 years in the kernel, I felt the LSM layer had established itself enough to justify a handful of syscalls. Support amongst the individual LSM developers has been nearly unanimous, with a single objection coming from Tetsuo (TOMOYO) as he is worried that the LSM_ID_XXX token concept will make it more difficult for out-of-tree LSMs to survive. Several members of the LSM community have demonstrated the ability for out-of-tree LSMs to continue to exist by picking high/unused LSM_ID values as well as pointing out that many kernel APIs rely on integer identifiers, e.g. syscalls (!), but unfortunately Tetsuo's objections remain. My personal opinion is that while I have no interest in penalizing out-of-tree LSMs, I'm not going to penalize in-tree development to support out-of-tree development, and I view this as a necessary step forward to support the push for expanded LSM stacking and reduce our reliance on /proc and /sys which has occassionally been problematic for some container users. Finally, we have included the linux-api folks on (all?) recent revisions of the patchset and addressed all of their concerns. - Add a new security_file_ioctl_compat() LSM hook to handle the 32-bit ioctls on 64-bit systems problem. This patch includes support for all of the existing LSMs which provide ioctl hooks, although it turns out only SELinux actually cares about the individual ioctls. It is worth noting that while Casey (Smack) and Tetsuo (TOMOYO) did not give explicit ACKs to this patch, they did both indicate they are okay with the changes. - Fix a potential memory leak in the CALIPSO code when IPv6 is disabled at boot. While it's good that we are fixing this, I doubt this is something users are seeing in the wild as you need to both disable IPv6 and then attempt to configure IPv6 labeled networking via NetLabel/CALIPSO; that just doesn't make much sense. Normally this would go through netdev, but Jakub asked me to take this patch and of all the trees I maintain, the LSM tree seemed like the best fit. - Update the LSM MAINTAINERS entry with additional information about our process docs, patchwork, bug reporting, etc. I also noticed that the Lockdown LSM is missing a dedicated MAINTAINERS entry so I've added that to the pull request. I've been working with one of the major Lockdown authors/contributors to see if they are willing to step up and assume a Lockdown maintainer role; hopefully that will happen soon, but in the meantime I'll continue to look after it. - Add a handful of mailmap entries for Serge Hallyn and myself. * tag 'lsm-pr-20240105' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: (27 commits) lsm: new security_file_ioctl_compat() hook lsm: Add a __counted_by() annotation to lsm_ctx.ctx calipso: fix memory leak in netlbl_calipso_add_pass() selftests: remove the LSM_ID_IMA check in lsm/lsm_list_modules_test MAINTAINERS: add an entry for the lockdown LSM MAINTAINERS: update the LSM entry mailmap: add entries for Serge Hallyn's dead accounts mailmap: update/replace my old email addresses lsm: mark the lsm_id variables are marked as static lsm: convert security_setselfattr() to use memdup_user() lsm: align based on pointer length in lsm_fill_user_ctx() lsm: consolidate buffer size handling into lsm_fill_user_ctx() lsm: correct error codes in security_getselfattr() lsm: cleanup the size counters in security_getselfattr() lsm: don't yet account for IMA in LSM_CONFIG_COUNT calculation lsm: drop LSM_ID_IMA LSM: selftests for Linux Security Module syscalls SELinux: Add selfattr hooks AppArmor: Add selfattr hooks Smack: implement setselfattr and getselfattr hooks ...
2 parents 9f9310b + f1bb47a commit 063a7ce

File tree

66 files changed

+1784
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1784
-122
lines changed

.mailmap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ Paul E. McKenney <paulmck@kernel.org> <paulmck@linux.vnet.ibm.com>
478478
Paul E. McKenney <paulmck@kernel.org> <paulmck@us.ibm.com>
479479
Paul Mackerras <paulus@ozlabs.org> <paulus@samba.org>
480480
Paul Mackerras <paulus@ozlabs.org> <paulus@au1.ibm.com>
481+
Paul Moore <paul@paul-moore.com> <paul.moore@hp.com>
482+
Paul Moore <paul@paul-moore.com> <pmoore@redhat.com>
481483
Pavankumar Kondeti <quic_pkondeti@quicinc.com> <pkondeti@codeaurora.org>
482484
Peter A Jonsson <pj@ludd.ltu.se>
483485
Peter Oruba <peter.oruba@amd.com>
@@ -542,6 +544,8 @@ Sebastian Reichel <sre@kernel.org> <sebastian.reichel@collabora.co.uk>
542544
Sebastian Reichel <sre@kernel.org> <sre@debian.org>
543545
Sedat Dilek <sedat.dilek@gmail.com> <sedat.dilek@credativ.de>
544546
Senthilkumar N L <quic_snlakshm@quicinc.com> <snlakshm@codeaurora.org>
547+
Serge Hallyn <sergeh@kernel.org> <serge.hallyn@canonical.com>
548+
Serge Hallyn <sergeh@kernel.org> <serue@us.ibm.com>
545549
Seth Forshee <sforshee@kernel.org> <seth.forshee@canonical.com>
546550
Shannon Nelson <shannon.nelson@amd.com> <snelson@pensando.io>
547551
Shannon Nelson <shannon.nelson@amd.com> <shannon.nelson@intel.com>

Documentation/userspace-api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ place where this information is gathered.
3333
sysfs-platform_profile
3434
vduse
3535
futex2
36+
lsm
3637

3738
.. only:: subproject and html
3839

Documentation/userspace-api/lsm.rst

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
.. Copyright (C) 2022 Casey Schaufler <casey@schaufler-ca.com>
3+
.. Copyright (C) 2022 Intel Corporation
4+
5+
=====================================
6+
Linux Security Modules
7+
=====================================
8+
9+
:Author: Casey Schaufler
10+
:Date: July 2023
11+
12+
Linux security modules (LSM) provide a mechanism to implement
13+
additional access controls to the Linux security policies.
14+
15+
The various security modules may support any of these attributes:
16+
17+
``LSM_ATTR_CURRENT`` is the current, active security context of the
18+
process.
19+
The proc filesystem provides this value in ``/proc/self/attr/current``.
20+
This is supported by the SELinux, Smack and AppArmor security modules.
21+
Smack also provides this value in ``/proc/self/attr/smack/current``.
22+
AppArmor also provides this value in ``/proc/self/attr/apparmor/current``.
23+
24+
``LSM_ATTR_EXEC`` is the security context of the process at the time the
25+
current image was executed.
26+
The proc filesystem provides this value in ``/proc/self/attr/exec``.
27+
This is supported by the SELinux and AppArmor security modules.
28+
AppArmor also provides this value in ``/proc/self/attr/apparmor/exec``.
29+
30+
``LSM_ATTR_FSCREATE`` is the security context of the process used when
31+
creating file system objects.
32+
The proc filesystem provides this value in ``/proc/self/attr/fscreate``.
33+
This is supported by the SELinux security module.
34+
35+
``LSM_ATTR_KEYCREATE`` is the security context of the process used when
36+
creating key objects.
37+
The proc filesystem provides this value in ``/proc/self/attr/keycreate``.
38+
This is supported by the SELinux security module.
39+
40+
``LSM_ATTR_PREV`` is the security context of the process at the time the
41+
current security context was set.
42+
The proc filesystem provides this value in ``/proc/self/attr/prev``.
43+
This is supported by the SELinux and AppArmor security modules.
44+
AppArmor also provides this value in ``/proc/self/attr/apparmor/prev``.
45+
46+
``LSM_ATTR_SOCKCREATE`` is the security context of the process used when
47+
creating socket objects.
48+
The proc filesystem provides this value in ``/proc/self/attr/sockcreate``.
49+
This is supported by the SELinux security module.
50+
51+
Kernel interface
52+
================
53+
54+
Set a security attribute of the current process
55+
-----------------------------------------------
56+
57+
.. kernel-doc:: security/lsm_syscalls.c
58+
:identifiers: sys_lsm_set_self_attr
59+
60+
Get the specified security attributes of the current process
61+
------------------------------------------------------------
62+
63+
.. kernel-doc:: security/lsm_syscalls.c
64+
:identifiers: sys_lsm_get_self_attr
65+
66+
.. kernel-doc:: security/lsm_syscalls.c
67+
:identifiers: sys_lsm_list_modules
68+
69+
Additional documentation
70+
========================
71+
72+
* Documentation/security/lsm.rst
73+
* Documentation/security/lsm-development.rst

MAINTAINERS

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12417,6 +12417,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/har
1241712417
F: Documentation/admin-guide/LSM/LoadPin.rst
1241812418
F: security/loadpin/
1241912419

12420+
LOCKDOWN SECURITY MODULE
12421+
L: linux-security-module@vger.kernel.org
12422+
S: Odd Fixes
12423+
T: git https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm.git
12424+
F: security/lockdown/
12425+
1242012426
LOCKING PRIMITIVES
1242112427
M: Peter Zijlstra <peterz@infradead.org>
1242212428
M: Ingo Molnar <mingo@redhat.com>
@@ -19455,12 +19461,17 @@ SECURITY SUBSYSTEM
1945519461
M: Paul Moore <paul@paul-moore.com>
1945619462
M: James Morris <jmorris@namei.org>
1945719463
M: "Serge E. Hallyn" <serge@hallyn.com>
19458-
L: linux-security-module@vger.kernel.org (suggested Cc:)
19464+
L: linux-security-module@vger.kernel.org
1945919465
S: Supported
19460-
W: http://kernsec.org/
19461-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm.git
19466+
Q: https://patchwork.kernel.org/project/linux-security-module/list
19467+
B: mailto:linux-security-module@vger.kernel.org
19468+
P: https://github.com/LinuxSecurityModule/kernel/blob/main/README.md
19469+
T: git https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm.git
19470+
F: include/uapi/linux/lsm.h
1946219471
F: security/
19472+
F: tools/testing/selftests/lsm/
1946319473
X: security/selinux/
19474+
K: \bsecurity_[a-z_0-9]\+\b
1946419475

1946519476
SELINUX SECURITY MODULE
1946619477
M: Paul Moore <paul@paul-moore.com>

arch/alpha/kernel/syscalls/syscall.tbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,6 @@
498498
566 common futex_requeue sys_futex_requeue
499499
567 common statmount sys_statmount
500500
568 common listmount sys_listmount
501+
569 common lsm_get_self_attr sys_lsm_get_self_attr
502+
570 common lsm_set_self_attr sys_lsm_set_self_attr
503+
571 common lsm_list_modules sys_lsm_list_modules

arch/arm/tools/syscall.tbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,6 @@
472472
456 common futex_requeue sys_futex_requeue
473473
457 common statmount sys_statmount
474474
458 common listmount sys_listmount
475+
459 common lsm_get_self_attr sys_lsm_get_self_attr
476+
460 common lsm_set_self_attr sys_lsm_set_self_attr
477+
461 common lsm_list_modules sys_lsm_list_modules

arch/arm64/include/asm/unistd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)
4040
#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800)
4141

42-
#define __NR_compat_syscalls 459
42+
#define __NR_compat_syscalls 462
4343
#endif
4444

4545
#define __ARCH_WANT_SYS_CLONE

arch/arm64/include/asm/unistd32.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,12 @@ __SYSCALL(__NR_futex_requeue, sys_futex_requeue)
923923
__SYSCALL(__NR_statmount, sys_statmount)
924924
#define __NR_listmount 458
925925
__SYSCALL(__NR_listmount, sys_listmount)
926+
#define __NR_lsm_get_self_attr 459
927+
__SYSCALL(__NR_lsm_get_self_attr, sys_lsm_get_self_attr)
928+
#define __NR_lsm_set_self_attr 460
929+
__SYSCALL(__NR_lsm_set_self_attr, sys_lsm_set_self_attr)
930+
#define __NR_lsm_list_modules 461
931+
__SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules)
926932

927933
/*
928934
* Please add new compat syscalls above this comment and update

arch/m68k/kernel/syscalls/syscall.tbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,6 @@
458458
456 common futex_requeue sys_futex_requeue
459459
457 common statmount sys_statmount
460460
458 common listmount sys_listmount
461+
459 common lsm_get_self_attr sys_lsm_get_self_attr
462+
460 common lsm_set_self_attr sys_lsm_set_self_attr
463+
461 common lsm_list_modules sys_lsm_list_modules

arch/microblaze/kernel/syscalls/syscall.tbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,6 @@
464464
456 common futex_requeue sys_futex_requeue
465465
457 common statmount sys_statmount
466466
458 common listmount sys_listmount
467+
459 common lsm_get_self_attr sys_lsm_get_self_attr
468+
460 common lsm_set_self_attr sys_lsm_set_self_attr
469+
461 common lsm_list_modules sys_lsm_list_modules

0 commit comments

Comments
 (0)