Skip to content
Snippets Groups Projects
  1. Mar 28, 2021
  2. Mar 22, 2021
    • Mimi Zohar's avatar
      integrity: double check iint_cache was initialized · 92063f3c
      Mimi Zohar authored
      
      The kernel may be built with multiple LSMs, but only a subset may be
      enabled on the boot command line by specifying "lsm=".  Not including
      "integrity" on the ordered LSM list may result in a NULL deref.
      
      As reported by Dmitry Vyukov:
      in qemu:
      qemu-system-x86_64       -enable-kvm     -machine q35,nvdimm -cpu
      max,migratable=off -smp 4       -m 4G,slots=4,maxmem=16G        -hda
      wheezy.img      -kernel arch/x86/boot/bzImage   -nographic -vga std
       -soundhw all     -usb -usbdevice tablet  -bt hci -bt device:keyboard
         -net user,host=10.0.2.10,hostfwd=tcp::10022-:22 -net
      nic,model=virtio-net-pci   -object
      memory-backend-file,id=pmem1,share=off,mem-path=/dev/zero,size=64M
        -device nvdimm,id=nvdimm1,memdev=pmem1  -append "console=ttyS0
      root=/dev/sda earlyprintk=serial rodata=n oops=panic panic_on_warn=1
      panic=86400 lsm=smack numa=fake=2 nopcid dummy_hcd.num=8"   -pidfile
      vm_pid -m 2G -cpu host
      
      But it crashes on NULL deref in integrity_inode_get during boot:
      
      Run /sbin/init as init process
      BUG: kernel NULL pointer dereference, address: 000000000000001c
      PGD 0 P4D 0
      Oops: 0000 [#1] PREEMPT SMP KASAN
      CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc2+ #97
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
      rel-1.13.0-44-g88ab0c15525c-prebuilt.qemu.org 04/01/2014
      RIP: 0010:kmem_cache_alloc+0x2b/0x370 mm/slub.c:2920
      Code: 57 41 56 41 55 41 54 41 89 f4 55 48 89 fd 53 48 83 ec 10 44 8b
      3d d9 1f 90 0b 65 48 8b 04 25 28 00 00 00 48 89 44 24 08 31 c0 <8b> 5f
      1c 4cf
      RSP: 0000:ffffc9000032f9d8 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff888017fc4f00 RCX: 0000000000000000
      RDX: ffff888040220000 RSI: 0000000000000c40 RDI: 0000000000000000
      RBP: 0000000000000000 R08: 0000000000000000 R09: ffff888019263627
      R10: ffffffff83937cd1 R11: 0000000000000000 R12: 0000000000000c40
      R13: ffff888019263538 R14: 0000000000000000 R15: 0000000000ffffff
      FS:  0000000000000000(0000) GS:ffff88802d180000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 000000000000001c CR3: 000000000b48e000 CR4: 0000000000750ee0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      PKRU: 55555554
      Call Trace:
       integrity_inode_get+0x47/0x260 security/integrity/iint.c:105
       process_measurement+0x33d/0x17e0 security/integrity/ima/ima_main.c:237
       ima_bprm_check+0xde/0x210 security/integrity/ima/ima_main.c:474
       security_bprm_check+0x7d/0xa0 security/security.c:845
       search_binary_handler fs/exec.c:1708 [inline]
       exec_binprm fs/exec.c:1761 [inline]
       bprm_execve fs/exec.c:1830 [inline]
       bprm_execve+0x764/0x19a0 fs/exec.c:1792
       kernel_execve+0x370/0x460 fs/exec.c:1973
       try_to_run_init_process+0x14/0x4e init/main.c:1366
       kernel_init+0x11d/0x1b8 init/main.c:1477
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
      Modules linked in:
      CR2: 000000000000001c
      ---[ end trace 22d601a500de7d79 ]---
      
      Since LSMs and IMA may be configured at build time, but not enabled at
      run time, panic the system if "integrity" was not initialized before use.
      
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Fixes: 79f7865d ("LSM: Introduce "lsm=" for boottime LSM selection")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      92063f3c
  3. Mar 19, 2021
    • Ondrej Mosnacek's avatar
      selinuxfs: unify policy load error reporting · ee5de60a
      Ondrej Mosnacek authored
      
      Let's drop the pr_err()s from sel_make_policy_nodes() and just add one
      pr_warn_ratelimited() call to the sel_make_policy_nodes() error path in
      sel_write_load().
      
      Changing from error to warning makes sense, since after 02a52c5c
      ("selinux: move policy commit after updating selinuxfs"), this error
      path no longer leads to a broken selinuxfs tree (it's just kept in the
      original state and policy load is aborted).
      
      I also added _ratelimited to be consistent with the other prtin in the
      same function (it's probably not necessary, but can't really hurt...
      there are likely more important error messages to be printed when
      filesystem entry creation starts erroring out).
      
      Suggested-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      ee5de60a
    • Ondrej Mosnacek's avatar
      selinux: fix variable scope issue in live sidtab conversion · 6406887a
      Ondrej Mosnacek authored
      
      Commit 02a52c5c ("selinux: move policy commit after updating
      selinuxfs") moved the selinux_policy_commit() call out of
      security_load_policy() into sel_write_load(), which caused a subtle yet
      rather serious bug.
      
      The problem is that security_load_policy() passes a reference to the
      convert_params local variable to sidtab_convert(), which stores it in
      the sidtab, where it may be accessed until the policy is swapped over
      and RCU synchronized. Before 02a52c5c, selinux_policy_commit() was
      called directly from security_load_policy(), so the convert_params
      pointer remained valid all the way until the old sidtab was destroyed,
      but now that's no longer the case and calls to sidtab_context_to_sid()
      on the old sidtab after security_load_policy() returns may cause invalid
      memory accesses.
      
      This can be easily triggered using the stress test from commit
      ee1a84fd ("selinux: overhaul sidtab to fix bug and improve
      performance"):
      ```
      function rand_cat() {
      	echo $(( $RANDOM % 1024 ))
      }
      
      function do_work() {
      	while true; do
      		echo -n "system_u:system_r:kernel_t:s0:c$(rand_cat),c$(rand_cat)" \
      			>/sys/fs/selinux/context 2>/dev/null || true
      	done
      }
      
      do_work >/dev/null &
      do_work >/dev/null &
      do_work >/dev/null &
      
      while load_policy; do echo -n .; sleep 0.1; done
      
      kill %1
      kill %2
      kill %3
      ```
      
      Fix this by allocating the temporary sidtab convert structures
      dynamically and passing them among the
      selinux_policy_{load,cancel,commit} functions.
      
      Fixes: 02a52c5c ("selinux: move policy commit after updating selinuxfs")
      Cc: stable@vger.kernel.org
      Tested-by: default avatarTyler Hicks <tyhicks@linux.microsoft.com>
      Reviewed-by: default avatarTyler Hicks <tyhicks@linux.microsoft.com>
      Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      [PM: merge fuzz in security.h and services.c]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      6406887a
    • Ondrej Mosnacek's avatar
      selinux: don't log MAC_POLICY_LOAD record on failed policy load · 519dad3b
      Ondrej Mosnacek authored
      
      If sel_make_policy_nodes() fails, we should jump to 'out', not 'out1',
      as the latter would incorrectly log an MAC_POLICY_LOAD audit record,
      even though the policy hasn't actually been reloaded. The 'out1' jump
      label now becomes unused and can be removed.
      
      Fixes: 02a52c5c ("selinux: move policy commit after updating selinuxfs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      519dad3b
  4. Mar 12, 2021
  5. Feb 16, 2021
    • Jarkko Sakkinen's avatar
      KEYS: trusted: Reserve TPM for seal and unseal operations · 8c657a05
      Jarkko Sakkinen authored
      
      When TPM 2.0 trusted keys code was moved to the trusted keys subsystem,
      the operations were unwrapped from tpm_try_get_ops() and tpm_put_ops(),
      which are used to take temporarily the ownership of the TPM chip. The
      ownership is only taken inside tpm_send(), but this is not sufficient,
      as in the key load TPM2_CC_LOAD, TPM2_CC_UNSEAL and TPM2_FLUSH_CONTEXT
      need to be done as a one single atom.
      
      Take the TPM chip ownership before sending anything with
      tpm_try_get_ops() and tpm_put_ops(), and use tpm_transmit_cmd() to send
      TPM commands instead of tpm_send(), reverting back to the old behaviour.
      
      Fixes: 2e19e101 ("KEYS: trusted: Move TPM2 trusted keys code")
      Reported-by: default avatar"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: stable@vger.kernel.org
      Cc: David Howells <dhowells@redhat.com>
      Cc: Mimi Zohar <zohar@linux.ibm.com>
      Cc: Sumit Garg <sumit.garg@linaro.org>
      Acked-by Sumit Garg <sumit.garg@linaro.org>
      Tested-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      8c657a05
    • Jarkko Sakkinen's avatar
      KEYS: trusted: Fix migratable=1 failing · 8da7520c
      Jarkko Sakkinen authored
      
      Consider the following transcript:
      
      $ keyctl add trusted kmk "new 32 blobauth=helloworld keyhandle=80000000 migratable=1" @u
      add_key: Invalid argument
      
      The documentation has the following description:
      
        migratable=   0|1 indicating permission to reseal to new PCR values,
                      default 1 (resealing allowed)
      
      The consequence is that "migratable=1" should succeed. Fix this by
      allowing this condition to pass instead of return -EINVAL.
      
      [*] Documentation/security/keys/trusted-encrypted.rst
      
      Cc: stable@vger.kernel.org
      Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
      Cc: Mimi Zohar <zohar@linux.ibm.com>
      Cc: David Howells <dhowells@redhat.com>
      Fixes: d00a1c72 ("keys: add new trusted key-type")
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      8da7520c
    • Jarkko Sakkinen's avatar
      KEYS: trusted: Fix incorrect handling of tpm_get_random() · 5df16caa
      Jarkko Sakkinen authored
      
      When tpm_get_random() was introduced, it defined the following API for the
      return value:
      
      1. A positive value tells how many bytes of random data was generated.
      2. A negative value on error.
      
      However, in the call sites the API was used incorrectly, i.e. as it would
      only return negative values and otherwise zero. Returning he positive read
      counts to the user space does not make any possible sense.
      
      Fix this by returning -EIO when tpm_get_random() returns a positive value.
      
      Fixes: 41ab999c ("tpm: Move tpm_get_random api into the TPM device driver")
      Cc: stable@vger.kernel.org
      Cc: Mimi Zohar <zohar@linux.ibm.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Kent Yoder <key@linux.vnet.ibm.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      5df16caa
  6. Feb 12, 2021
  7. Feb 10, 2021
  8. Feb 03, 2021
  9. Feb 01, 2021
  10. Jan 28, 2021
    • Miklos Szeredi's avatar
      cap: fix conversions on getxattr · f2b00be4
      Miklos Szeredi authored
      
      If a capability is stored on disk in v2 format cap_inode_getsecurity() will
      currently return in v2 format unconditionally.
      
      This is wrong: v2 cap should be equivalent to a v3 cap with zero rootid,
      and so the same conversions performed on it.
      
      If the rootid cannot be mapped, v3 is returned unconverted.  Fix this so
      that both v2 and v3 return -EOVERFLOW if the rootid (or the owner of the fs
      user namespace in case of v2) cannot be mapped into the current user
      namespace.
      
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      f2b00be4
  11. Jan 27, 2021
    • Raphael Gianotti's avatar
      IMA: Measure kernel version in early boot · b3f82afc
      Raphael Gianotti authored
      
      The integrity of a kernel can be verified by the boot loader on cold
      boot, and during kexec, by the current running kernel, before it is
      loaded. However, it is still possible that the new kernel being
      loaded is older than the current kernel, and/or has known
      vulnerabilities. Therefore, it is imperative that an attestation
      service be able to verify the version of the kernel being loaded on
      the client, from cold boot and subsequent kexec system calls,
      ensuring that only kernels with versions known to be good are loaded.
      
      Measure the kernel version using ima_measure_critical_data() early on
      in the boot sequence, reducing the chances of known kernel
      vulnerabilities being exploited. With IMA being part of the kernel,
      this overall approach makes the measurement itself more trustworthy.
      
      To enable measuring the kernel version "ima_policy=critical_data"
      needs to be added to the kernel command line arguments.
      For example,
              BOOT_IMAGE=/boot/vmlinuz-5.11.0-rc3+ root=UUID=fd643309-a5d2-4ed3-b10d-3c579a5fab2f ro nomodeset ima_policy=critical_data
      
      If runtime measurement of the kernel version is ever needed, the
      following should be added to /etc/ima/ima-policy:
      
              measure func=CRITICAL_DATA label=kernel_info
      
      To extract the measured data after boot, the following command can be used:
      
              grep -m 1 "kernel_version" \
              /sys/kernel/security/integrity/ima/ascii_runtime_measurements
      
      Sample output from the command above:
      
              10 a8297d408e9d5155728b619761d0dd4cedf5ef5f ima-buf
              sha256:5660e19945be0119bc19cbbf8d9c33a09935ab5d30dad48aa11f879c67d70988
              kernel_version 352e31312e302d7263332d31363138372d676564623634666537383234342d6469727479
      
      The above hex-ascii string corresponds to the kernel version
      (e.g. xxd -r -p):
      
              5.11.0-rc3-16187-gedb64fe78244-dirty
      
      Signed-off-by: default avatarRaphael Gianotti <raphgi@linux.microsoft.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      b3f82afc
  12. Jan 24, 2021
    • Christian Brauner's avatar
      ima: handle idmapped mounts · a2d2329e
      Christian Brauner authored
      IMA does sometimes access the inode's i_uid and compares it against the
      rules' fowner. Enable IMA to handle idmapped mounts by passing down the
      mount's user namespace. We simply make use of the helpers we introduced
      before. 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-27-christian.brauner@ubuntu.com
      
      
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      a2d2329e
    • Christian Brauner's avatar
      apparmor: handle idmapped mounts · 3cee6079
      Christian Brauner authored
      The i_uid and i_gid are mostly used when logging for AppArmor. This is
      broken in a bunch of places where the global root id is reported instead
      of the i_uid or i_gid of the file. Nonetheless, be kind and log the
      mapped inode if we're coming from an idmapped mount. 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-26-christian.brauner@ubuntu.com
      
      
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      3cee6079
    • Christian Brauner's avatar
      fs: make helpers idmap mount aware · 549c7297
      Christian Brauner authored
      Extend some inode methods with an additional user namespace argument. A
      filesystem that is aware of idmapped mounts will receive the user
      namespace the mount has been marked with. This can be used for
      additional permission checking and also to enable filesystems to
      translate between uids and gids if they need to. We have implemented all
      relevant helpers in earlier patches.
      
      As requested we simply extend the exisiting inode method instead of
      introducing new ones. This is a little more code churn but it's mostly
      mechanical and doesnt't leave us with additional inode methods.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-25-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: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      549c7297
    • Christian Brauner's avatar
      commoncap: handle idmapped mounts · 71bc356f
      Christian Brauner authored
      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: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      71bc356f
    • Tycho Andersen's avatar
      xattr: handle idmapped mounts · c7c7a1a1
      Tycho Andersen authored
      When interacting with extended attributes the vfs verifies that the
      caller is privileged over the inode with which the extended attribute is
      associated. For posix access and posix default extended attributes a uid
      or gid can be stored on-disk. Let the functions handle posix extended
      attributes on idmapped mounts. If the inode is accessed through an
      idmapped mount we need to map it according to the mount's user
      namespace. Afterwards the checks are identical to non-idmapped mounts.
      This has no effect for e.g. security xattrs since they don't store uids
      or gids and don't perform permission checks on them like posix acls do.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-10-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: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: default avatarTycho Andersen <tycho@tycho.pizza>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      c7c7a1a1
    • Christian Brauner's avatar
      acl: handle idmapped mounts · e65ce2a5
      Christian Brauner authored
      The posix acl permission checking helpers determine whether a caller is
      privileged over an inode according to the acls associated with the
      inode. Add helpers that make it possible to handle acls on idmapped
      mounts.
      
      The vfs and the filesystems targeted by this first iteration make use of
      posix_acl_fix_xattr_from_user() and posix_acl_fix_xattr_to_user() to
      translate basic posix access and default permissions such as the
      ACL_USER and ACL_GROUP type according to the initial user namespace (or
      the superblock's user namespace) to and from the caller's current user
      namespace. Adapt these two helpers to handle idmapped mounts whereby we
      either map from or into the mount's user namespace depending on in which
      direction we're translating.
      Similarly, cap_convert_nscap() is used by the vfs to translate user
      namespace and non-user namespace aware filesystem capabilities from the
      superblock's user namespace to the caller's user namespace. Enable it to
      handle idmapped mounts by accounting for the mount's user namespace.
      
      In addition the fileystems targeted in the first iteration of this patch
      series make use of the posix_acl_chmod() and, posix_acl_update_mode()
      helpers. Both helpers perform permission checks on the target inode. Let
      them handle idmapped mounts. These two helpers are called when posix
      acls are set by the respective filesystems to handle this case we extend
      the ->set() method to take an additional user namespace argument to pass
      the mount's user namespace down.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-9-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: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      e65ce2a5
    • Christian Brauner's avatar
      inode: make init and permission helpers idmapped mount aware · 21cb47be
      Christian Brauner authored
      The inode_owner_or_capable() helper determines whether the caller is the
      owner of the inode or is capable with respect to that inode. Allow it to
      handle idmapped mounts. If the inode is accessed through an idmapped
      mount it according to the mount's user namespace. Afterwards the checks
      are identical to non-idmapped mounts. If the initial user namespace is
      passed nothing changes so non-idmapped mounts will see identical
      behavior as before.
      
      Similarly, allow the inode_init_owner() helper to handle idmapped
      mounts. It initializes a new inode on idmapped mounts by mapping the
      fsuid and fsgid of the caller from the mount's 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-7-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: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      21cb47be
    • Christian Brauner's avatar
      capability: handle idmapped mounts · 0558c1bf
      Christian Brauner authored
      In order to determine whether a caller holds privilege over a given
      inode the capability framework exposes the two helpers
      privileged_wrt_inode_uidgid() and capable_wrt_inode_uidgid(). The former
      verifies that the inode has a mapping in the caller's user namespace and
      the latter additionally verifies that the caller has the requested
      capability in their current user namespace.
      If the inode is accessed through an idmapped mount map it into the
      mount's user namespace. Afterwards the checks are identical to
      non-idmapped inodes. If the initial user namespace is passed all
      operations are a nop so non-idmapped mounts will not see a change in
      behavior.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-5-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: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      Acked-by: default avatarSerge Hallyn <serge@hallyn.com>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      0558c1bf
  13. Jan 21, 2021
  14. Jan 16, 2021
  15. Jan 15, 2021
Loading