1. 01 3月, 2022 1 次提交
  2. 05 1月, 2022 1 次提交
    • B
      ima: silence measurement list hexdump during kexec · 520451e9
      Bruno Meneguele 提交于
      Directly calling print_hex_dump() dumps the IMA measurement list on soft
      resets (kexec) straight to the syslog (kmsg/dmesg) without considering the
      DEBUG flag or the dynamic debug state, causing the output to be always
      printed, including during boot time.
      
      Since this output is only valid for IMA debugging, but not necessary on
      normal kexec operation, print_hex_dump_debug() adheres to the pr_debug()
      behavior: the dump is only printed to syslog when DEBUG is defined or when
      explicitly requested by the user through dynamic debugging.
      Signed-off-by: NBruno Meneguele <bmeneg@redhat.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      520451e9
  3. 27 12月, 2021 1 次提交
    • T
      selinux: initialize proto variable in selinux_ip_postroute_compat() · 732bc2ff
      Tom Rix 提交于
      Clang static analysis reports this warning
      
      hooks.c:5765:6: warning: 4th function call argument is an uninitialized
                      value
              if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto))
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      selinux_parse_skb() can return ok without setting proto.  The later call
      to selinux_xfrm_postroute_last() does an early check of proto and can
      return ok if the garbage proto value matches.  So initialize proto.
      
      Cc: stable@vger.kernel.org
      Fixes: eef9b416 ("selinux: cleanup selinux_xfrm_sock_rcv_skb() and selinux_xfrm_postroute_last()")
      Signed-off-by: NTom Rix <trix@redhat.com>
      [PM: typo/spelling and checkpatch.pl description fixes]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      732bc2ff
  4. 24 12月, 2021 1 次提交
  5. 22 12月, 2021 2 次提交
  6. 17 12月, 2021 2 次提交
    • J
      add missing bpf-cgroup.h includes · aef2feda
      Jakub Kicinski 提交于
      We're about to break the cgroup-defs.h -> bpf-cgroup.h dependency,
      make sure those who actually need more than the definition of
      struct cgroup_bpf include bpf-cgroup.h explicitly.
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NTejun Heo <tj@kernel.org>
      Link: https://lore.kernel.org/bpf/20211216025538.1649516-3-kuba@kernel.org
      aef2feda
    • S
      selinux: fix sleeping function called from invalid context · cc274ae7
      Scott Mayhew 提交于
      selinux_sb_mnt_opts_compat() is called via sget_fc() under the sb_lock
      spinlock, so it can't use GFP_KERNEL allocations:
      
      [  868.565200] BUG: sleeping function called from invalid context at
                     include/linux/sched/mm.h:230
      [  868.568246] in_atomic(): 1, irqs_disabled(): 0,
                     non_block: 0, pid: 4914, name: mount.nfs
      [  868.569626] preempt_count: 1, expected: 0
      [  868.570215] RCU nest depth: 0, expected: 0
      [  868.570809] Preemption disabled at:
      [  868.570810] [<0000000000000000>] 0x0
      [  868.571848] CPU: 1 PID: 4914 Comm: mount.nfs Kdump: loaded
                     Tainted: G        W         5.16.0-rc5.2585cf9d #1
      [  868.573273] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009),
                     BIOS 1.14.0-4.fc34 04/01/2014
      [  868.574478] Call Trace:
      [  868.574844]  <TASK>
      [  868.575156]  dump_stack_lvl+0x34/0x44
      [  868.575692]  __might_resched.cold+0xd6/0x10f
      [  868.576308]  slab_pre_alloc_hook.constprop.0+0x89/0xf0
      [  868.577046]  __kmalloc_track_caller+0x72/0x420
      [  868.577684]  ? security_context_to_sid_core+0x48/0x2b0
      [  868.578569]  kmemdup_nul+0x22/0x50
      [  868.579108]  security_context_to_sid_core+0x48/0x2b0
      [  868.579854]  ? _nfs4_proc_pathconf+0xff/0x110 [nfsv4]
      [  868.580742]  ? nfs_reconfigure+0x80/0x80 [nfs]
      [  868.581355]  security_context_str_to_sid+0x36/0x40
      [  868.581960]  selinux_sb_mnt_opts_compat+0xb5/0x1e0
      [  868.582550]  ? nfs_reconfigure+0x80/0x80 [nfs]
      [  868.583098]  security_sb_mnt_opts_compat+0x2a/0x40
      [  868.583676]  nfs_compare_super+0x113/0x220 [nfs]
      [  868.584249]  ? nfs_try_mount_request+0x210/0x210 [nfs]
      [  868.584879]  sget_fc+0xb5/0x2f0
      [  868.585267]  nfs_get_tree_common+0x91/0x4a0 [nfs]
      [  868.585834]  vfs_get_tree+0x25/0xb0
      [  868.586241]  fc_mount+0xe/0x30
      [  868.586605]  do_nfs4_mount+0x130/0x380 [nfsv4]
      [  868.587160]  nfs4_try_get_tree+0x47/0xb0 [nfsv4]
      [  868.587724]  vfs_get_tree+0x25/0xb0
      [  868.588193]  do_new_mount+0x176/0x310
      [  868.588782]  __x64_sys_mount+0x103/0x140
      [  868.589388]  do_syscall_64+0x3b/0x90
      [  868.589935]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [  868.590699] RIP: 0033:0x7f2b371c6c4e
      [  868.591239] Code: 48 8b 0d dd 71 0e 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e
                           0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 a5 00
                           00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d aa 71
                           0e 00 f7 d8 64 89 01 48
      [  868.593810] RSP: 002b:00007ffc83775d88 EFLAGS: 00000246
                     ORIG_RAX: 00000000000000a5
      [  868.594691] RAX: ffffffffffffffda RBX: 00007ffc83775f10 RCX: 00007f2b371c6c4e
      [  868.595504] RDX: 0000555d517247a0 RSI: 0000555d51724700 RDI: 0000555d51724540
      [  868.596317] RBP: 00007ffc83775f10 R08: 0000555d51726890 R09: 0000555d51726890
      [  868.597162] R10: 0000000000000000 R11: 0000000000000246 R12: 0000555d51726890
      [  868.598005] R13: 0000000000000003 R14: 0000555d517246e0 R15: 0000555d511ac925
      [  868.598826]  </TASK>
      
      Cc: stable@vger.kernel.org
      Fixes: 69c4a42d ("lsm,selinux: add new hook to compare new mount to an existing mount")
      Signed-off-by: NScott Mayhew <smayhew@redhat.com>
      [PM: cleanup/line-wrap the backtrace]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      cc274ae7
  7. 15 12月, 2021 2 次提交
    • T
      tomoyo: use hwight16() in tomoyo_domain_quota_is_ok() · f702e110
      Tetsuo Handa 提交于
      hwight16() is much faster. While we are at it, no need to include
      "perm =" part into data_race() macro, for perm is a local variable
      that cannot be accessed by other threads.
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      f702e110
    • D
      tomoyo: Check exceeded quota early in tomoyo_domain_quota_is_ok(). · 04e57a2d
      Dmitry Vyukov 提交于
      If tomoyo is used in a testing/fuzzing environment in learning mode,
      for lots of domains the quota will be exceeded and stay exceeded
      for prolonged periods of time. In such cases it's pointless (and slow)
      to walk the whole acl list again and again just to rediscover that
      the quota is exceeded. We already have the TOMOYO_DIF_QUOTA_WARNED flag
      that notes the overflow condition. Check it early to avoid the slowdown.
      
      [penguin-kernel]
      This patch causes a user visible change that the learning mode will not be
      automatically resumed after the quota is increased. To resume the learning
      mode, administrator will need to explicitly clear TOMOYO_DIF_QUOTA_WARNED
      flag after increasing the quota. But I think that this change is generally
      preferable, for administrator likely wants to optimize the acl list for
      that domain before increasing the quota, or that domain likely hits the
      quota again. Therefore, don't try to care to clear TOMOYO_DIF_QUOTA_WARNED
      flag automatically when the quota for that domain changed.
      Signed-off-by: NDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      04e57a2d
  8. 07 12月, 2021 1 次提交
  9. 06 12月, 2021 1 次提交
  10. 05 12月, 2021 1 次提交
    • C
      fs: support mapped mounts of mapped filesystems · bd303368
      Christian Brauner 提交于
      In previous patches we added new and modified existing helpers to handle
      idmapped mounts of filesystems mounted with an idmapping. In this final
      patch we convert all relevant places in the vfs to actually pass the
      filesystem's idmapping into these helpers.
      
      With this the vfs is in shape to handle idmapped mounts of filesystems
      mounted with an idmapping. Note that this is just the generic
      infrastructure. Actually adding support for idmapped mounts to a
      filesystem mountable with an idmapping is follow-up work.
      
      In this patch we extend the definition of an idmapped mount from a mount
      that that has the initial idmapping attached to it to a mount that has
      an idmapping attached to it which is not the same as the idmapping the
      filesystem was mounted with.
      
      As before we do not allow the initial idmapping to be attached to a
      mount. In addition this patch prevents that the idmapping the filesystem
      was mounted with can be attached to a mount created based on this
      filesystem.
      
      This has multiple reasons and advantages. First, attaching the initial
      idmapping or the filesystem's idmapping doesn't make much sense as in
      both cases the values of the i_{g,u}id and other places where k{g,u}ids
      are used do not change. Second, a user that really wants to do this for
      whatever reason can just create a separate dedicated identical idmapping
      to attach to the mount. Third, we can continue to use the initial
      idmapping as an indicator that a mount is not idmapped allowing us to
      continue to keep passing the initial idmapping into the mapping helpers
      to tell them that something isn't an idmapped mount even if the
      filesystem is mounted with an idmapping.
      
      Link: https://lore.kernel.org/r/20211123114227.3124056-11-brauner@kernel.org (v1)
      Link: https://lore.kernel.org/r/20211130121032.3753852-11-brauner@kernel.org (v2)
      Link: https://lore.kernel.org/r/20211203111707.3901969-11-brauner@kernel.org
      Cc: Seth Forshee <sforshee@digitalocean.com>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Christoph Hellwig <hch@lst.de>
      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 <christian.brauner@ubuntu.com>
      bd303368
  11. 04 12月, 2021 2 次提交
  12. 26 11月, 2021 2 次提交
  13. 23 11月, 2021 1 次提交
  14. 20 11月, 2021 1 次提交
    • O
      selinux: fix NULL-pointer dereference when hashtab allocation fails · dc27f3c5
      Ondrej Mosnacek 提交于
      When the hash table slot array allocation fails in hashtab_init(),
      h->size is left initialized with a non-zero value, but the h->htable
      pointer is NULL. This may then cause a NULL pointer dereference, since
      the policydb code relies on the assumption that even after a failed
      hashtab_init(), hashtab_map() and hashtab_destroy() can be safely called
      on it. Yet, these detect an empty hashtab only by looking at the size.
      
      Fix this by making sure that hashtab_init() always leaves behind a valid
      empty hashtab when the allocation fails.
      
      Cc: stable@vger.kernel.org
      Fixes: 03414a49 ("selinux: do not allocate hashtabs dynamically")
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      dc27f3c5
  15. 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
  16. 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
  17. 07 11月, 2021 1 次提交
  18. 04 11月, 2021 3 次提交
  19. 03 11月, 2021 8 次提交
  20. 02 11月, 2021 1 次提交
  21. 29 10月, 2021 1 次提交
  22. 22 10月, 2021 2 次提交
  23. 21 10月, 2021 1 次提交
  24. 20 10月, 2021 2 次提交
    • E
      ucounts: Move get_ucounts from cred_alloc_blank to key_change_session_keyring · 5ebcbe34
      Eric W. Biederman 提交于
      Setting cred->ucounts in cred_alloc_blank does not make sense.  The
      uid and user_ns are deliberately not set in cred_alloc_blank but
      instead the setting is delayed until key_change_session_keyring.
      
      So move dealing with ucounts into key_change_session_keyring as well.
      
      Unfortunately that movement of get_ucounts adds a new failure mode to
      key_change_session_keyring.  I do not see anything stopping the parent
      process from calling setuid and changing the relevant part of it's
      cred while keyctl_session_to_parent is running making it fundamentally
      necessary to call get_ucounts in key_change_session_keyring.  Which
      means that the new failure mode cannot be avoided.
      
      A failure of key_change_session_keyring results in a single threaded
      parent keeping it's existing credentials.  Which results in the parent
      process not being able to access the session keyring and whichever
      keys are in the new keyring.
      
      Further get_ucounts is only expected to fail if the number of bits in
      the refernece count for the structure is too few.
      
      Since the code has no other way to report the failure of get_ucounts
      and because such failures are not expected to be common add a WARN_ONCE
      to report this problem to userspace.
      
      Between the WARN_ONCE and the parent process not having access to
      the keys in the new session keyring I expect any failure of get_ucounts
      will be noticed and reported and we can find another way to handle this
      condition.  (Possibly by just making ucounts->count an atomic_long_t).
      
      Cc: stable@vger.kernel.org
      Fixes: 905ae01c ("Add a reference to ucounts for each cred")
      Link: https://lkml.kernel.org/r/7k0ias0uf.fsf_-_@disp2133Tested-by: NYu Zhao <yuzhao@google.com>
      Reviewed-by: NAlexey Gladkov <legion@kernel.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      5ebcbe34
    • V
      security: Return xattr name from security_dentry_init_security() · 15bf3239
      Vivek Goyal 提交于
      Right now security_dentry_init_security() only supports single security
      label and is used by SELinux only. There are two users of this hook,
      namely ceph and nfs.
      
      NFS does not care about xattr name. Ceph hardcodes the xattr name to
      security.selinux (XATTR_NAME_SELINUX).
      
      I am making changes to fuse/virtiofs to send security label to virtiofsd
      and I need to send xattr name as well. I also hardcoded the name of
      xattr to security.selinux.
      
      Stephen Smalley suggested that it probably is a good idea to modify
      security_dentry_init_security() to also return name of xattr so that
      we can avoid this hardcoding in the callers.
      
      This patch adds a new parameter "const char **xattr_name" to
      security_dentry_init_security() and LSM puts the name of xattr
      too if caller asked for it (xattr_name != NULL).
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NJeff Layton <jlayton@kernel.org>
      Reviewed-by: NChristian Brauner <christian.brauner@ubuntu.com>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      [PM: fixed typos in the commit description]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      15bf3239