Merge tag 'landlock_v34' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 2 May 2021 01:50:44 +0000 (18:50 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 2 May 2021 01:50:44 +0000 (18:50 -0700)
Pull Landlock LSM from James Morris:
 "Add Landlock, a new LSM from Mickaël Salaün.

  Briefly, Landlock provides for unprivileged application sandboxing.

  From Mickaël's cover letter:
    "The goal of Landlock is to enable to restrict ambient rights (e.g.
     global filesystem access) for a set of processes. Because Landlock
     is a stackable LSM [1], it makes possible to create safe security
     sandboxes as new security layers in addition to the existing
     system-wide access-controls. This kind of sandbox is expected to
     help mitigate the security impact of bugs or unexpected/malicious
     behaviors in user-space applications. Landlock empowers any
     process, including unprivileged ones, to securely restrict
     themselves.

     Landlock is inspired by seccomp-bpf but instead of filtering
     syscalls and their raw arguments, a Landlock rule can restrict the
     use of kernel objects like file hierarchies, according to the
     kernel semantic. Landlock also takes inspiration from other OS
     sandbox mechanisms: XNU Sandbox, FreeBSD Capsicum or OpenBSD
     Pledge/Unveil.

     In this current form, Landlock misses some access-control features.
     This enables to minimize this patch series and ease review. This
     series still addresses multiple use cases, especially with the
     combined use of seccomp-bpf: applications with built-in sandboxing,
     init systems, security sandbox tools and security-oriented APIs [2]"

  The cover letter and v34 posting is here:

      https://lore.kernel.org/linux-security-module/20210422154123.13086-1-mic@digikod.net/

  See also:

      https://landlock.io/

  This code has had extensive design discussion and review over several
  years"

Link: https://lore.kernel.org/lkml/50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com/
Link: https://lore.kernel.org/lkml/f646e1c7-33cf-333f-070c-0a40ad0468cd@digikod.net/
* tag 'landlock_v34' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
  landlock: Enable user space to infer supported features
  landlock: Add user and kernel documentation
  samples/landlock: Add a sandbox manager example
  selftests/landlock: Add user space tests
  landlock: Add syscall implementations
  arch: Wire up Landlock syscalls
  fs,security: Add sb_delete hook
  landlock: Support filesystem access-control
  LSM: Infrastructure management of the superblock
  landlock: Add ptrace restrictions
  landlock: Set up the security framework and manage credentials
  landlock: Add ruleset and domain management
  landlock: Add object management

31 files changed:
1  2 
Documentation/userspace-api/index.rst
MAINTAINERS
arch/Kconfig
arch/alpha/kernel/syscalls/syscall.tbl
arch/arm/tools/syscall.tbl
arch/arm64/include/asm/unistd32.h
arch/ia64/kernel/syscalls/syscall.tbl
arch/m68k/kernel/syscalls/syscall.tbl
arch/microblaze/kernel/syscalls/syscall.tbl
arch/mips/kernel/syscalls/syscall_n32.tbl
arch/mips/kernel/syscalls/syscall_n64.tbl
arch/mips/kernel/syscalls/syscall_o32.tbl
arch/parisc/kernel/syscalls/syscall.tbl
arch/powerpc/kernel/syscalls/syscall.tbl
arch/s390/kernel/syscalls/syscall.tbl
arch/sh/kernel/syscalls/syscall.tbl
arch/sparc/kernel/syscalls/syscall.tbl
arch/x86/entry/syscalls/syscall_32.tbl
arch/x86/entry/syscalls/syscall_64.tbl
arch/xtensa/kernel/syscalls/syscall.tbl
include/linux/lsm_hook_defs.h
include/linux/lsm_hooks.h
include/linux/security.h
include/linux/syscalls.h
include/uapi/asm-generic/unistd.h
kernel/sys_ni.c
security/security.c
security/selinux/hooks.c
security/selinux/ss/services.c
security/smack/smack.h
security/smack/smack_lsm.c

Simple merge
diff --cc MAINTAINERS
Simple merge
diff --cc arch/Kconfig
Simple merge
index c5f7e595adab48d44a59e21fdfaf81d35434883a,4240f21b10b33d5063e77d3f92548cb96532c61c..5622578742fdde44e9c6a28955923438795f1b4e
  550   common  process_madvise                 sys_process_madvise
  551   common  epoll_pwait2                    sys_epoll_pwait2
  552   common  mount_setattr                   sys_mount_setattr
 +553   common  quotactl_path                   sys_quotactl_path
+ 554   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 555   common  landlock_add_rule               sys_landlock_add_rule
+ 556   common  landlock_restrict_self          sys_landlock_restrict_self
index 90cbe207cf3e7160b5ab12ff418efb760c48cdfb,161423a5d773b973771deafc4f378426f6319048..c7679d7db98b0cf689b9d549569effb71ca72128
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index 8361c5138e5f975cf5683a1546b4ca7ea5413539,fdfe06bae3fcace3aeacff49ac59659996ed9e58..7859749d6628a5d0bf4ed758d03b25e5d3c0ac19
@@@ -893,8 -893,12 +893,14 @@@ __SYSCALL(__NR_process_madvise, sys_pro
  __SYSCALL(__NR_epoll_pwait2, compat_sys_epoll_pwait2)
  #define __NR_mount_setattr 442
  __SYSCALL(__NR_mount_setattr, sys_mount_setattr)
 +#define __NR_quotactl_path 443
 +__SYSCALL(__NR_quotactl_path, sys_quotactl_path)
+ #define __NR_landlock_create_ruleset 444
+ __SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset)
+ #define __NR_landlock_add_rule 445
+ __SYSCALL(__NR_landlock_add_rule, sys_landlock_add_rule)
+ #define __NR_landlock_restrict_self 446
+ __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self)
  
  /*
   * Please add new compat syscalls above this comment and update
index c072cd459bb5472ac621096d45e2fd1a6f46e66d,48dbbc95a01fa64167d46b93b86d6082d4cf59c0..1ee8e736a48e37d73c5137e17154741777292a61
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index 5e9f81073ff4f1bdb6e1d964594ff4e982867c8b,595108bbbe428e3c5fa8146df2af8ee3bdd863b6..0dd019dc21362d18360269261f4f69977aa1cf3b
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index 8e74d690c64d248d421d958884baeba798c865c9,db23d65871f9be741167b9013b2aba438c6ed0cf..2ac716984ca2869112ad4847c56eda8803dc83f7
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index 6f397e56926f196e61d3b56fb9afb488a32d59f0,5028839225fa6213a32f4489f3dd1e06231b1603..5e009665725104d960b1c0a1d066a4470f324abc
  440   n32     process_madvise                 sys_process_madvise
  441   n32     epoll_pwait2                    compat_sys_epoll_pwait2
  442   n32     mount_setattr                   sys_mount_setattr
 +443   n32     quotactl_path                   sys_quotactl_path
+ 444   n32     landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   n32     landlock_add_rule               sys_landlock_add_rule
+ 446   n32     landlock_restrict_self          sys_landlock_restrict_self
index ab85a357c4fa6db6670e50f3d699ccebf9354f25,ec9c68b75e234e5a8e605f241e233619e5276252..9974f5f8e49bce05819434ff65479b98caf85b91
  440   n64     process_madvise                 sys_process_madvise
  441   n64     epoll_pwait2                    sys_epoll_pwait2
  442   n64     mount_setattr                   sys_mount_setattr
 +443   n64     quotactl_path                   sys_quotactl_path
+ 444   n64     landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   n64     landlock_add_rule               sys_landlock_add_rule
+ 446   n64     landlock_restrict_self          sys_landlock_restrict_self
index 9c4cd2b40b38393f6a51ba94cd1d58fbf6797a1a,24afd33e3e495afc66c40f024bdefa75e2921188..39d6e71e57b608866fda81de210974076d0ca8cb
  440   o32     process_madvise                 sys_process_madvise
  441   o32     epoll_pwait2                    sys_epoll_pwait2                compat_sys_epoll_pwait2
  442   o32     mount_setattr                   sys_mount_setattr
 +443   o32     quotactl_path                   sys_quotactl_path
+ 444   o32     landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   o32     landlock_add_rule               sys_landlock_add_rule
+ 446   o32     landlock_restrict_self          sys_landlock_restrict_self
index 80fba3f7d47b2868e71f22b2c9ff53e59c8f429a,8ddd0b82d7670222b79d7ef30007fe459e1e955f..5ac80b83d745e19020d37af6175b6da495a9a1ca
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2                compat_sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index f66f9c9b9d6cf4b7af7029e6da1710bd5efd8e21,02150894b1cfe4924f240ad33ec727a6b4497b77..2e68fbb57cc66de2e451c9e9721d425d9d76d9c1
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2                compat_sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index a421905c36e884a47e33e6877255961e7e6adf42,331663efd3e704f218026ec483831211347ce1d2..7e4a2aba366df088e153856f93f94cb0be0a2b4e
  440  common   process_madvise         sys_process_madvise             sys_process_madvise
  441  common   epoll_pwait2            sys_epoll_pwait2                compat_sys_epoll_pwait2
  442  common   mount_setattr           sys_mount_setattr               sys_mount_setattr
 +443  common   quotactl_path           sys_quotactl_path               sys_quotactl_path
+ 444  common   landlock_create_ruleset sys_landlock_create_ruleset     sys_landlock_create_ruleset
+ 445  common   landlock_add_rule       sys_landlock_add_rule           sys_landlock_add_rule
+ 446  common   landlock_restrict_self  sys_landlock_restrict_self      sys_landlock_restrict_self
index f68517aaa4f1866d131848bf22572ba04f53fbd0,6ada711f4b72a6a452803e886b8b26abbd6faeb5..f47a0dc5544551961efff6287c860ab347f90f05
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index 3ee82321504d3995283d6d6ee8495f946b9454f8,1dbe3239a638121aa8ac49e5489bcdbc7bc2a47b..b9e1c0e735b72b6ea50a862e401dd3afa39eb7f7
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2                compat_sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
index f52a443eede017558604e78487a673b489cce723,782c310de1dad2a7402cd175e2268700dd1b1589..28a1423ce32ee54e4e9b193d8f104b828acb5c96
  440   i386    process_madvise         sys_process_madvise
  441   i386    epoll_pwait2            sys_epoll_pwait2                compat_sys_epoll_pwait2
  442   i386    mount_setattr           sys_mount_setattr
 +443   i386    quotactl_path           sys_quotactl_path
+ 444   i386    landlock_create_ruleset sys_landlock_create_ruleset
+ 445   i386    landlock_add_rule       sys_landlock_add_rule
+ 446   i386    landlock_restrict_self  sys_landlock_restrict_self
index 7eb007b8cab5978b11ada91581954ea214c25768,8604ee4bfff9b8cc12dcf09e6f720e41795f95da..ecd551b08d05256af7235764c72d711460b2d58a
  440   common  process_madvise         sys_process_madvise
  441   common  epoll_pwait2            sys_epoll_pwait2
  442   common  mount_setattr           sys_mount_setattr
 +443   common  quotactl_path           sys_quotactl_path
+ 444   common  landlock_create_ruleset sys_landlock_create_ruleset
+ 445   common  landlock_add_rule       sys_landlock_add_rule
+ 446   common  landlock_restrict_self  sys_landlock_restrict_self
  
  #
  # Due to a historical design error, certain syscalls are numbered differently
index c71cc45633deca15654abdfeae378429b503adca,2fad056a32e84e75f1452ba16c664ce123713087..9d76d433d3d67012b73ae48fc7232e0294a92973
  440   common  process_madvise                 sys_process_madvise
  441   common  epoll_pwait2                    sys_epoll_pwait2
  442   common  mount_setattr                   sys_mount_setattr
 +443   common  quotactl_path                   sys_quotactl_path
+ 444   common  landlock_create_ruleset         sys_landlock_create_ruleset
+ 445   common  landlock_add_rule               sys_landlock_add_rule
+ 446   common  landlock_restrict_self          sys_landlock_restrict_self
Simple merge
Simple merge
Simple merge
Simple merge
index 739c839d28fef3500d02a2b8f3bfec1f3f1d5eef,300608b052263b47972fd86570b3075aa5e3c392..6de5a7fc066b8fd4ca47dd276e0b899fad1658cf
@@@ -863,11 -863,15 +863,18 @@@ __SYSCALL(__NR_process_madvise, sys_pro
  __SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2)
  #define __NR_mount_setattr 442
  __SYSCALL(__NR_mount_setattr, sys_mount_setattr)
 +#define __NR_quotactl_path 443
 +__SYSCALL(__NR_quotactl_path, sys_quotactl_path)
 +
+ #define __NR_landlock_create_ruleset 444
+ __SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset)
+ #define __NR_landlock_add_rule 445
+ __SYSCALL(__NR_landlock_add_rule, sys_landlock_add_rule)
+ #define __NR_landlock_restrict_self 446
+ __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self)
  #undef __NR_syscalls
- #define __NR_syscalls 444
+ #define __NR_syscalls 447
  
  /*
   * 32 bit systems traditionally used different
diff --cc kernel/sys_ni.c
Simple merge
Simple merge
index 92f909a2e8f71e50c0d7678984497a152d174515,2ed9c995263ab6766fe082c9a1ed9f9a81c06a12..eaea837d89d1f8506a571328b8a1b2e9f1355d22
@@@ -7165,9 -7062,7 +7152,8 @@@ static struct security_hook_list selinu
        LSM_HOOK_INIT(bprm_committing_creds, selinux_bprm_committing_creds),
        LSM_HOOK_INIT(bprm_committed_creds, selinux_bprm_committed_creds),
  
-       LSM_HOOK_INIT(sb_free_security, selinux_sb_free_security),
        LSM_HOOK_INIT(sb_free_mnt_opts, selinux_free_mnt_opts),
 +      LSM_HOOK_INIT(sb_mnt_opts_compat, selinux_sb_mnt_opts_compat),
        LSM_HOOK_INIT(sb_remount, selinux_sb_remount),
        LSM_HOOK_INIT(sb_kern_mount, selinux_sb_kern_mount),
        LSM_HOOK_INIT(sb_show_options, selinux_sb_show_options),
index f0ba826113437a1ed79dee31908eafccc81a8859,9cea2e6c809ff438799003504feea1288ae261e7..0a5ce001609b37a772915122c5d4779eec974d1c
@@@ -2953,9 -2874,9 +2954,9 @@@ int security_fs_use(struct selinux_stat
        struct selinux_policy *policy;
        struct policydb *policydb;
        struct sidtab *sidtab;
 -      int rc = 0;
 +      int rc;
        struct ocontext *c;
-       struct superblock_security_struct *sbsec = sb->s_security;
+       struct superblock_security_struct *sbsec = selinux_superblock(sb);
        const char *fstype = sb->s_type->name;
  
        if (!selinux_initialized(state)) {
Simple merge
Simple merge