1. 16 7月, 2022 1 次提交
  2. 27 6月, 2022 1 次提交
    • C
      security: pass down mount idmapping to setattr hook · 0e363cf3
      Christian Brauner 提交于
      Before this change we used to take a shortcut and place the actual
      values that would be written to inode->i_{g,u}id into struct iattr. This
      had the advantage that we moved idmappings mostly out of the picture
      early on but it made reasoning about changes more difficult than it
      should be.
      
      The filesystem was never explicitly told that it dealt with an idmapped
      mount. The transition to the value that needed to be stored in
      inode->i_{g,u}id appeared way too early and increased the probability of
      bugs in various codepaths.
      
      We know place the same value in struct iattr no matter if this is an
      idmapped mount or not. The vfs will only deal with type safe
      vfs{g,u}id_t. This makes it massively safer to perform permission checks
      as the type will tell us what checks we need to perform and what helpers
      we need to use.
      
      Adapt the security_inode_setattr() helper to pass down the mount's
      idmapping to account for that change.
      
      Link: https://lore.kernel.org/r/20220621141454.2914719-8-brauner@kernel.org
      Cc: Seth Forshee <sforshee@digitalocean.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Aleksa Sarai <cyphar@cyphar.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      CC: linux-fsdevel@vger.kernel.org
      Reviewed-by: NSeth Forshee <sforshee@digitalocean.com>
      Signed-off-by: NChristian Brauner (Microsoft) <brauner@kernel.org>
      0e363cf3
  3. 25 5月, 2022 1 次提交
  4. 23 5月, 2022 1 次提交
  5. 14 5月, 2022 1 次提交
  6. 14 4月, 2022 1 次提交
  7. 16 2月, 2022 1 次提交
  8. 29 1月, 2022 1 次提交
    • V
      security, lsm: dentry_init_security() Handle multi LSM registration · 7f5056b9
      Vivek Goyal 提交于
      A ceph user has reported that ceph is crashing with kernel NULL pointer
      dereference. Following is the backtrace.
      
      /proc/version: Linux version 5.16.2-arch1-1 (linux@archlinux) (gcc (GCC)
      11.1.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Thu, 20 Jan 2022
      16:18:29 +0000
      distro / arch: Arch Linux / x86_64
      SELinux is not enabled
      ceph cluster version: 16.2.7 (dd0603118f56ab514f133c8d2e3adfc983942503)
      
      relevant dmesg output:
      [   30.947129] BUG: kernel NULL pointer dereference, address:
      0000000000000000
      [   30.947206] #PF: supervisor read access in kernel mode
      [   30.947258] #PF: error_code(0x0000) - not-present page
      [   30.947310] PGD 0 P4D 0
      [   30.947342] Oops: 0000 [#1] PREEMPT SMP PTI
      [   30.947388] CPU: 5 PID: 778 Comm: touch Not tainted 5.16.2-arch1-1 #1
      86fbf2c313cc37a553d65deb81d98e9dcc2a3659
      [   30.947486] Hardware name: Gigabyte Technology Co., Ltd. B365M
      DS3H/B365M DS3H, BIOS F5 08/13/2019
      [   30.947569] RIP: 0010:strlen+0x0/0x20
      [   30.947616] Code: b6 07 38 d0 74 16 48 83 c7 01 84 c0 74 05 48 39 f7 75
      ec 31 c0 31 d2 89 d6 89 d7 c3 48 89 f8 31 d2 89 d6 89 d7 c3 0
      f 1f 40 00 <80> 3f 00 74 12 48 89 f8 48 83 c0 01 80 38 00 75 f7 48 29 f8 31
      ff
      [   30.947782] RSP: 0018:ffffa4ed80ffbbb8 EFLAGS: 00010246
      [   30.947836] RAX: 0000000000000000 RBX: ffffa4ed80ffbc60 RCX:
      0000000000000000
      [   30.947904] RDX: 0000000000000000 RSI: 0000000000000000 RDI:
      0000000000000000
      [   30.947971] RBP: ffff94b0d15c0ae0 R08: 0000000000000000 R09:
      0000000000000000
      [   30.948040] R10: 0000000000000000 R11: 0000000000000000 R12:
      0000000000000000
      [   30.948106] R13: 0000000000000001 R14: ffffa4ed80ffbc60 R15:
      0000000000000000
      [   30.948174] FS:  00007fc7520f0740(0000) GS:ffff94b7ced40000(0000)
      knlGS:0000000000000000
      [   30.948252] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   30.948308] CR2: 0000000000000000 CR3: 0000000104a40001 CR4:
      00000000003706e0
      [   30.948376] Call Trace:
      [   30.948404]  <TASK>
      [   30.948431]  ceph_security_init_secctx+0x7b/0x240 [ceph
      49f9c4b9bf5be8760f19f1747e26da33920bce4b]
      [   30.948582]  ceph_atomic_open+0x51e/0x8a0 [ceph
      49f9c4b9bf5be8760f19f1747e26da33920bce4b]
      [   30.948708]  ? get_cached_acl+0x4d/0xa0
      [   30.948759]  path_openat+0x60d/0x1030
      [   30.948809]  do_filp_open+0xa5/0x150
      [   30.948859]  do_sys_openat2+0xc4/0x190
      [   30.948904]  __x64_sys_openat+0x53/0xa0
      [   30.948948]  do_syscall_64+0x5c/0x90
      [   30.948989]  ? exc_page_fault+0x72/0x180
      [   30.949034]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [   30.949091] RIP: 0033:0x7fc7521e25bb
      [   30.950849] Code: 25 00 00 41 00 3d 00 00 41 00 74 4b 64 8b 04 25 18 00
      00 00 85 c0 75 67 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 0
      0 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 54 24 28 64 48 2b 14
      25
      
      Core of the problem is that ceph checks for return code from
      security_dentry_init_security() and if return code is 0, it assumes
      everything is fine and continues to call strlen(name), which crashes.
      
      Typically SELinux LSM returns 0 and sets name to "security.selinux" and
      it is not a problem. Or if selinux is not compiled in or disabled, it
      returns -EOPNOTSUP and ceph deals with it.
      
      But somehow in this configuration, 0 is being returned and "name" is
      not being initialized and that's creating the problem.
      
      Our suspicion is that BPF LSM is registering a hook for
      dentry_init_security() and returns hook default of 0.
      
      LSM_HOOK(int, 0, dentry_init_security, struct dentry *dentry,...)
      
      I have not been able to reproduce it just by doing CONFIG_BPF_LSM=y.
      Stephen has tested the patch though and confirms it solves the problem
      for him.
      
      dentry_init_security() is written in such a way that it expects only one
      LSM to register the hook. Atleast that's the expectation with current code.
      
      If another LSM returns a hook and returns default, it will simply return
      0 as of now and that will break ceph.
      
      Hence, suggestion is that change semantics of this hook a bit. If there
      are no LSMs or no LSM is taking ownership and initializing security context,
      then return -EOPNOTSUP. Also allow at max one LSM to initialize security
      context. This hook can't deal with multiple LSMs trying to init security
      context. This patch implements this new behavior.
      Reported-by: NStephen Muth <smuth4@gmail.com>
      Tested-by: NStephen Muth <smuth4@gmail.com>
      Suggested-by: NCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Reviewed-by: NSerge Hallyn <serge@hallyn.com>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: <stable@vger.kernel.org> # 5.16.0
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NJeff Layton <jlayton@kernel.org>
      Acked-by: NPaul Moore <paul@paul-moore.com>
      Acked-by: NChristian Brauner <brauner@kernel.org>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      7f5056b9
  9. 28 1月, 2022 1 次提交
    • C
      LSM: general protection fault in legacy_parse_param · ecff3057
      Casey Schaufler 提交于
      The usual LSM hook "bail on fail" scheme doesn't work for cases where
      a security module may return an error code indicating that it does not
      recognize an input.  In this particular case Smack sees a mount option
      that it recognizes, and returns 0. A call to a BPF hook follows, which
      returns -ENOPARAM, which confuses the caller because Smack has processed
      its data.
      
      The SELinux hook incorrectly returns 1 on success. There was a time
      when this was correct, however the current expectation is that it
      return 0 on success. This is repaired.
      
      Reported-by: syzbot+d1e3b1d92d25abf97943@syzkaller.appspotmail.com
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      ecff3057
  10. 07 12月, 2021 1 次提交
  11. 23 11月, 2021 1 次提交
  12. 14 11月, 2021 1 次提交
    • P
      net,lsm,selinux: revert the security_sctp_assoc_established() hook · 1aa3b220
      Paul Moore 提交于
      This patch reverts two prior patches, e7310c94
      ("security: implement sctp_assoc_established hook in selinux") and
      7c2ef024 ("security: add sctp_assoc_established hook"), which
      create the security_sctp_assoc_established() LSM hook and provide a
      SELinux implementation.  Unfortunately these two patches were merged
      without proper review (the Reviewed-by and Tested-by tags from
      Richard Haines were for previous revisions of these patches that
      were significantly different) and there are outstanding objections
      from the SELinux maintainers regarding these patches.
      
      Work is currently ongoing to correct the problems identified in the
      reverted patches, as well as others that have come up during review,
      but it is unclear at this point in time when that work will be ready
      for inclusion in the mainline kernel.  In the interest of not keeping
      objectionable code in the kernel for multiple weeks, and potentially
      a kernel release, we are reverting the two problematic patches.
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1aa3b220
  13. 13 11月, 2021 1 次提交
    • P
      net,lsm,selinux: revert the security_sctp_assoc_established() hook · 32a370ab
      Paul Moore 提交于
      This patch reverts two prior patches, e7310c94
      ("security: implement sctp_assoc_established hook in selinux") and
      7c2ef024 ("security: add sctp_assoc_established hook"), which
      create the security_sctp_assoc_established() LSM hook and provide a
      SELinux implementation.  Unfortunately these two patches were merged
      without proper review (the Reviewed-by and Tested-by tags from
      Richard Haines were for previous revisions of these patches that
      were significantly different) and there are outstanding objections
      from the SELinux maintainers regarding these patches.
      
      Work is currently ongoing to correct the problems identified in the
      reverted patches, as well as others that have come up during review,
      but it is unclear at this point in time when that work will be ready
      for inclusion in the mainline kernel.  In the interest of not keeping
      objectionable code in the kernel for multiple weeks, and potentially
      a kernel release, we are reverting the two problematic patches.
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      32a370ab
  14. 03 11月, 2021 2 次提交
  15. 20 10月, 2021 1 次提交
  16. 15 10月, 2021 2 次提交
    • T
      binder: use cred instead of task for selinux checks · 52f88693
      Todd Kjos 提交于
      Since binder was integrated with selinux, it has passed
      'struct task_struct' associated with the binder_proc
      to represent the source and target of transactions.
      The conversion of task to SID was then done in the hook
      implementations. It turns out that there are race conditions
      which can result in an incorrect security context being used.
      
      Fix by using the 'struct cred' saved during binder_open and pass
      it to the selinux subsystem.
      
      Cc: stable@vger.kernel.org # 5.14 (need backport for earlier stables)
      Fixes: 79af7307 ("Add security hooks to binder and implement the hooks for SELinux.")
      Suggested-by: NJann Horn <jannh@google.com>
      Signed-off-by: NTodd Kjos <tkjos@google.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      52f88693
    • K
      LSM: Avoid warnings about potentially unused hook variables · 86dd9fd5
      Kees Cook 提交于
      Building with W=1 shows many unused const variable warnings. These can
      be silenced, as we're well aware of their being potentially unused:
      
      ./include/linux/lsm_hook_defs.h:36:18: error: 'ptrace_access_check_default' defined but not used [-Werror=unused-const-variable=]
         36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
            |                  ^~~~~~~~~~~~~~~~~~~
      security/security.c:706:32: note: in definition of macro 'LSM_RET_DEFAULT'
        706 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
            |                                ^~~~
      security/security.c:711:9: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
        711 |         DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
            |         ^~~~~~~~~~~~~~~~~~~~~~~~
      ./include/linux/lsm_hook_defs.h:36:1: note: in expansion of macro 'LSM_HOOK'
         36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
            | ^~~~~~~~
      
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Casey Schaufler <casey@schaufler-ca.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: linux-security-module@vger.kernel.org
      Reported-by: Nkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/linux-mm/202110131608.zms53FPR-lkp@intel.com/
      Fixes: 98e828a0 ("security: Refactor declaration of LSM hooks")
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      86dd9fd5
  17. 20 9月, 2021 1 次提交
    • P
      lsm,io_uring: add LSM hooks to io_uring · cdc1404a
      Paul Moore 提交于
      A full expalantion of io_uring is beyond the scope of this commit
      description, but in summary it is an asynchronous I/O mechanism
      which allows for I/O requests and the resulting data to be queued
      in memory mapped "rings" which are shared between the kernel and
      userspace.  Optionally, io_uring offers the ability for applications
      to spawn kernel threads to dequeue I/O requests from the ring and
      submit the requests in the kernel, helping to minimize the syscall
      overhead.  Rings are accessed in userspace by memory mapping a file
      descriptor provided by the io_uring_setup(2), and can be shared
      between applications as one might do with any open file descriptor.
      Finally, process credentials can be registered with a given ring
      and any process with access to that ring can submit I/O requests
      using any of the registered credentials.
      
      While the io_uring functionality is widely recognized as offering a
      vastly improved, and high performing asynchronous I/O mechanism, its
      ability to allow processes to submit I/O requests with credentials
      other than its own presents a challenge to LSMs.  When a process
      creates a new io_uring ring the ring's credentials are inhertied
      from the calling process; if this ring is shared with another
      process operating with different credentials there is the potential
      to bypass the LSMs security policy.  Similarly, registering
      credentials with a given ring allows any process with access to that
      ring to submit I/O requests with those credentials.
      
      In an effort to allow LSMs to apply security policy to io_uring I/O
      operations, this patch adds two new LSM hooks.  These hooks, in
      conjunction with the LSM anonymous inode support previously
      submitted, allow an LSM to apply access control policy to the
      sharing of io_uring rings as well as any io_uring credential changes
      requested by a process.
      
      The new LSM hooks are described below:
      
       * int security_uring_override_creds(cred)
         Controls if the current task, executing an io_uring operation,
         is allowed to override it's credentials with @cred.  In cases
         where the current task is a user application, the current
         credentials will be those of the user application.  In cases
         where the current task is a kernel thread servicing io_uring
         requests the current credentials will be those of the io_uring
         ring (inherited from the process that created the ring).
      
       * int security_uring_sqpoll(void)
         Controls if the current task is allowed to create an io_uring
         polling thread (IORING_SETUP_SQPOLL).  Without a SQPOLL thread
         in the kernel processes must submit I/O requests via
         io_uring_enter(2) which allows us to compare any requested
         credential changes against the application making the request.
         With a SQPOLL thread, we can no longer compare requested
         credential changes against the application making the request,
         the comparison is made against the ring's credentials.
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      cdc1404a
  18. 10 8月, 2021 2 次提交
    • D
      bpf: Add lockdown check for probe_write_user helper · 51e1bb9e
      Daniel Borkmann 提交于
      Back then, commit 96ae5227 ("bpf: Add bpf_probe_write_user BPF helper
      to be called in tracers") added the bpf_probe_write_user() helper in order
      to allow to override user space memory. Its original goal was to have a
      facility to "debug, divert, and manipulate execution of semi-cooperative
      processes" under CAP_SYS_ADMIN. Write to kernel was explicitly disallowed
      since it would otherwise tamper with its integrity.
      
      One use case was shown in cf9b1199 ("samples/bpf: Add test/example of
      using bpf_probe_write_user bpf helper") where the program DNATs traffic
      at the time of connect(2) syscall, meaning, it rewrites the arguments to
      a syscall while they're still in userspace, and before the syscall has a
      chance to copy the argument into kernel space. These days we have better
      mechanisms in BPF for achieving the same (e.g. for load-balancers), but
      without having to write to userspace memory.
      
      Of course the bpf_probe_write_user() helper can also be used to abuse
      many other things for both good or bad purpose. Outside of BPF, there is
      a similar mechanism for ptrace(2) such as PTRACE_PEEK{TEXT,DATA} and
      PTRACE_POKE{TEXT,DATA}, but would likely require some more effort.
      Commit 96ae5227 explicitly dedicated the helper for experimentation
      purpose only. Thus, move the helper's availability behind a newly added
      LOCKDOWN_BPF_WRITE_USER lockdown knob so that the helper is disabled under
      the "integrity" mode. More fine-grained control can be implemented also
      from LSM side with this change.
      
      Fixes: 96ae5227 ("bpf: Add bpf_probe_write_user BPF helper to be called in tracers")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      51e1bb9e
    • D
      bpf: Add _kernel suffix to internal lockdown_bpf_read · 71330842
      Daniel Borkmann 提交于
      Rename LOCKDOWN_BPF_READ into LOCKDOWN_BPF_READ_KERNEL so we have naming
      more consistent with a LOCKDOWN_BPF_WRITE_USER option that we are adding.
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      71330842
  19. 22 5月, 2021 1 次提交
  20. 11 5月, 2021 1 次提交
  21. 23 4月, 2021 2 次提交
  22. 23 3月, 2021 2 次提交
    • P
      lsm: separate security_task_getsecid() into subjective and objective variants · 4ebd7651
      Paul Moore 提交于
      Of the three LSMs that implement the security_task_getsecid() LSM
      hook, all three LSMs provide the task's objective security
      credentials.  This turns out to be unfortunate as most of the hook's
      callers seem to expect the task's subjective credentials, although
      a small handful of callers do correctly expect the objective
      credentials.
      
      This patch is the first step towards fixing the problem: it splits
      the existing security_task_getsecid() hook into two variants, one
      for the subjective creds, one for the objective creds.
      
        void security_task_getsecid_subj(struct task_struct *p,
      				   u32 *secid);
        void security_task_getsecid_obj(struct task_struct *p,
      				  u32 *secid);
      
      While this patch does fix all of the callers to use the correct
      variant, in order to keep this patch focused on the callers and to
      ease review, the LSMs continue to use the same implementation for
      both hooks.  The net effect is that this patch should not change
      the behavior of the kernel in any way, it will be up to the latter
      LSM specific patches in this series to change the hook
      implementations and return the correct credentials.
      
      Acked-by: Mimi Zohar <zohar@linux.ibm.com> (IMA)
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Reviewed-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      4ebd7651
    • O
      lsm,selinux: add new hook to compare new mount to an existing mount · 69c4a42d
      Olga Kornievskaia 提交于
      Add a new hook that takes an existing super block and a new mount
      with new options and determines if new options confict with an
      existing mount or not.
      
      A filesystem can use this new hook to determine if it can share
      the an existing superblock with a new superblock for the new mount.
      Signed-off-by: NOlga Kornievskaia <kolga@netapp.com>
      Acked-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      [PM: tweak the subject line, fix tab/space problems]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      69c4a42d
  23. 24 1月, 2021 1 次提交
    • C
      commoncap: handle idmapped mounts · 71bc356f
      Christian Brauner 提交于
      When interacting with user namespace and non-user namespace aware
      filesystem capabilities the vfs will perform various security checks to
      determine whether or not the filesystem capabilities can be used by the
      caller, whether they need to be removed and so on. The main
      infrastructure for this resides in the capability codepaths but they are
      called through the LSM security infrastructure even though they are not
      technically an LSM or optional. This extends the existing security hooks
      security_inode_removexattr(), security_inode_killpriv(),
      security_inode_getsecurity() to pass down the mount's user namespace and
      makes them aware of idmapped mounts.
      
      In order to actually get filesystem capabilities from disk the
      capability infrastructure exposes the get_vfs_caps_from_disk() helper.
      For user namespace aware filesystem capabilities a root uid is stored
      alongside the capabilities.
      
      In order to determine whether the caller can make use of the filesystem
      capability or whether it needs to be ignored it is translated according
      to the superblock's user namespace. If it can be translated to uid 0
      according to that id mapping the caller can use the filesystem
      capabilities stored on disk. If we are accessing the inode that holds
      the filesystem capabilities through an idmapped mount we map the root
      uid according to the mount's user namespace. Afterwards the checks are
      identical to non-idmapped mounts: reading filesystem caps from disk
      enforces that the root uid associated with the filesystem capability
      must have a mapping in the superblock's user namespace and that the
      caller is either in the same user namespace or is a descendant of the
      superblock's user namespace. For filesystems that are mountable inside
      user namespace the caller can just mount the filesystem and won't
      usually need to idmap it. If they do want to idmap it they can create an
      idmapped mount and mark it with a user namespace they created and which
      is thus a descendant of s_user_ns. For filesystems that are not
      mountable inside user namespaces the descendant rule is trivially true
      because the s_user_ns will be the initial user namespace.
      
      If the initial user namespace is passed nothing changes so non-idmapped
      mounts will see identical behavior as before.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-11-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      71bc356f
  24. 15 1月, 2021 1 次提交
    • L
      security: add inode_init_security_anon() LSM hook · 215b674b
      Lokesh Gidra 提交于
      This change adds a new LSM hook, inode_init_security_anon(), that will
      be used while creating secure anonymous inodes. The hook allows/denies
      its creation and assigns a security context to the inode.
      
      The new hook accepts an optional context_inode parameter that callers
      can use to provide additional contextual information to security modules
      for granting/denying permission to create an anon-inode of the same type.
      This context_inode's security_context can also be used to initialize the
      newly created anon-inode's security_context.
      Signed-off-by: NLokesh Gidra <lokeshgidra@google.com>
      Reviewed-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      215b674b
  25. 04 12月, 2020 1 次提交
  26. 27 11月, 2020 1 次提交
    • A
      xfrm: redact SA secret with lockdown confidentiality · c7a5899e
      Antony Antony 提交于
      redact XFRM SA secret in the netlink response to xfrm_get_sa()
      or dumpall sa.
      Enable lockdown, confidentiality mode, at boot or at run time.
      
      e.g. when enabled:
      cat /sys/kernel/security/lockdown
      none integrity [confidentiality]
      
      ip xfrm state
      src 172.16.1.200 dst 172.16.1.100
      	proto esp spi 0x00000002 reqid 2 mode tunnel
      	replay-window 0
      	aead rfc4106(gcm(aes)) 0x0000000000000000000000000000000000000000 96
      
      note: the aead secret is redacted.
      Redacting secret is also a FIPS 140-2 requirement.
      
      v1->v2
       - add size checks before memset calls
      v2->v3
       - replace spaces with tabs for consistency
      v3->v4
       - use kernel lockdown instead of a /proc setting
      v4->v5
       - remove kconfig option
      Reviewed-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NAntony Antony <antony.antony@secunet.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      c7a5899e
  27. 24 11月, 2020 1 次提交
  28. 05 10月, 2020 3 次提交
  29. 24 6月, 2020 1 次提交
    • K
      security: Fix hook iteration and default value for inode_copy_up_xattr · 23e390cd
      KP Singh 提交于
      inode_copy_up_xattr returns 0 to indicate the acceptance of the xattr
      and 1 to reject it. If the LSM does not know about the xattr, it's
      expected to return -EOPNOTSUPP, which is the correct default value for
      this hook. BPF LSM, currently, uses 0 as the default value and thereby
      falsely allows all overlay fs xattributes to be copied up.
      
      The iteration logic is also updated from the "bail-on-fail"
      call_int_hook to continue on the non-decisive -EOPNOTSUPP and bail out
      on other values.
      
      Fixes: 98e828a0 ("security: Refactor declaration of LSM hooks")
      Signed-off-by: NKP Singh <kpsingh@google.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      23e390cd
  30. 15 6月, 2020 1 次提交
  31. 03 6月, 2020 1 次提交
  32. 30 5月, 2020 1 次提交
    • E
      exec: Compute file based creds only once · 56305aa9
      Eric W. Biederman 提交于
      Move the computation of creds from prepare_binfmt into begin_new_exec
      so that the creds need only be computed once.  This is just code
      reorganization no semantic changes of any kind are made.
      
      Moving the computation is safe.  I have looked through the kernel and
      verified none of the binfmts look at bprm->cred directly, and that
      there are no helpers that look at bprm->cred indirectly.  Which means
      that it is not a problem to compute the bprm->cred later in the
      execution flow as it is not used until it becomes current->cred.
      
      A new function bprm_creds_from_file is added to contain the work that
      needs to be done.  bprm_creds_from_file first computes which file
      bprm->executable or most likely bprm->file that the bprm->creds
      will be computed from.
      
      The funciton bprm_fill_uid is updated to receive the file instead of
      accessing bprm->file.  The now unnecessary work needed to reset the
      bprm->cred->euid, and bprm->cred->egid is removed from brpm_fill_uid.
      A small comment to document that bprm_fill_uid now only deals with the
      work to handle suid and sgid files.  The default case is already
      heandled by prepare_exec_creds.
      
      The function security_bprm_repopulate_creds is renamed
      security_bprm_creds_from_file and now is explicitly passed the file
      from which to compute the creds.  The documentation of the
      bprm_creds_from_file security hook is updated to explain when the hook
      is called and what it needs to do.  The file is passed from
      cap_bprm_creds_from_file into get_file_caps so that the caps are
      computed for the appropriate file.  The now unnecessary work in
      cap_bprm_creds_from_file to reset the ambient capabilites has been
      removed.  A small comment to document that the work of
      cap_bprm_creds_from_file is to read capabilities from the files
      secureity attribute and derive capabilities from the fact the
      user had uid 0 has been added.
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      56305aa9
  33. 23 5月, 2020 1 次提交