1. 01 3月, 2022 1 次提交
  2. 23 11月, 2021 1 次提交
  3. 22 10月, 2021 2 次提交
  4. 14 10月, 2021 1 次提交
  5. 12 10月, 2021 1 次提交
  6. 29 9月, 2021 1 次提交
  7. 25 9月, 2021 1 次提交
    • S
      smack: Guard smack_ipv6_lock definition within a SMACK_IPV6_PORT_LABELING block · 222a96b3
      Sebastian Andrzej Siewior 提交于
      The mutex smack_ipv6_lock is only used with the SMACK_IPV6_PORT_LABELING
      block but its definition is outside of the block. This leads to a
      defined-but-not-used warning on PREEMPT_RT.
      
      Moving smack_ipv6_lock down to the block where it is used where it used
      raises the question why is smk_ipv6_port_list read if nothing is added
      to it.
      Turns out, only smk_ipv6_port_check() is using it outside of an ifdef
      SMACK_IPV6_PORT_LABELING block. However two of three caller invoke
      smk_ipv6_port_check() from a ifdef block and only one is using
      __is_defined() macro which requires the function and smk_ipv6_port_list
      to be around.
      
      Put the lock and list inside an ifdef SMACK_IPV6_PORT_LABELING block to
      avoid the warning regarding unused mutex. Extend the ifdef-block to also
      cover smk_ipv6_port_check(). Make smack_socket_connect() use ifdef
      instead of __is_defined() to avoid complains about missing function.
      
      Cc: Casey Schaufler <casey@schaufler-ca.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      222a96b3
  8. 24 9月, 2021 1 次提交
    • P
      selinux,smack: fix subjective/objective credential use mixups · a3727a8b
      Paul Moore 提交于
      Jann Horn reported a problem with commit eb1231f7 ("selinux:
      clarify task subjective and objective credentials") where some LSM
      hooks were attempting to access the subjective credentials of a task
      other than the current task.  Generally speaking, it is not safe to
      access another task's subjective credentials and doing so can cause
      a number of problems.
      
      Further, while looking into the problem, I realized that Smack was
      suffering from a similar problem brought about by a similar commit
      1fb057dc ("smack: differentiate between subjective and objective
      task credentials").
      
      This patch addresses this problem by restoring the use of the task's
      objective credentials in those cases where the task is other than the
      current executing task.  Not only does this resolve the problem
      reported by Jann, it is arguably the correct thing to do in these
      cases.
      
      Cc: stable@vger.kernel.org
      Fixes: eb1231f7 ("selinux: clarify task subjective and objective credentials")
      Fixes: 1fb057dc ("smack: differentiate between subjective and objective task credentials")
      Reported-by: NJann Horn <jannh@google.com>
      Acked-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      a3727a8b
  9. 20 9月, 2021 1 次提交
  10. 16 9月, 2021 1 次提交
  11. 21 7月, 2021 2 次提交
  12. 09 6月, 2021 1 次提交
    • C
      Smack: fix doc warning · fe6bde73
      ChenXiaoSong 提交于
      Fix gcc W=1 warning:
      
      security/smack/smack_access.c:342: warning: Function parameter or member 'ad' not described in 'smack_log'
      security/smack/smack_access.c:403: warning: Function parameter or member 'skp' not described in 'smk_insert_entry'
      security/smack/smack_access.c:487: warning: Function parameter or member 'level' not described in 'smk_netlbl_mls'
      security/smack/smack_access.c:487: warning: Function parameter or member 'len' not described in 'smk_netlbl_mls'
      Signed-off-by: NChenXiaoSong <chenxiaosong2@huawei.com>
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      fe6bde73
  13. 19 5月, 2021 1 次提交
  14. 11 5月, 2021 2 次提交
  15. 23 4月, 2021 1 次提交
  16. 23 3月, 2021 2 次提交
  17. 03 2月, 2021 1 次提交
    • S
      smackfs: restrict bytes count in smackfs write functions · 7ef4c19d
      Sabyrzhan Tasbolatov 提交于
      syzbot found WARNINGs in several smackfs write operations where
      bytes count is passed to memdup_user_nul which exceeds
      GFP MAX_ORDER. Check count size if bigger than PAGE_SIZE.
      
      Per smackfs doc, smk_write_net4addr accepts any label or -CIPSO,
      smk_write_net6addr accepts any label or -DELETE. I couldn't find
      any general rule for other label lengths except SMK_LABELLEN,
      SMK_LONGLABEL, SMK_CIPSOMAX which are documented.
      
      Let's constrain, in general, smackfs label lengths for PAGE_SIZE.
      Although fuzzer crashes write to smackfs/netlabel on 0x400000 length.
      
      Here is a quick way to reproduce the WARNING:
      python -c "print('A' * 0x400000)" > /sys/fs/smackfs/netlabel
      
      Reported-by: syzbot+a71a442385a0b2815497@syzkaller.appspotmail.com
      Signed-off-by: NSabyrzhan Tasbolatov <snovitoll@gmail.com>
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      7ef4c19d
  18. 24 1月, 2021 2 次提交
    • 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
    • T
      xattr: handle idmapped mounts · c7c7a1a1
      Tycho Andersen 提交于
      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: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NTycho Andersen <tycho@tycho.pizza>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      c7c7a1a1
  19. 23 12月, 2020 1 次提交
  20. 04 12月, 2020 1 次提交
  21. 17 11月, 2020 1 次提交
  22. 14 11月, 2020 1 次提交
    • A
      Smack: fix kernel-doc interface on functions · 7da31b85
      Alex Shi 提交于
      The are some kernel-doc interface issues:
      security/smack/smackfs.c:1950: warning: Function parameter or member
      'list' not described in 'smk_parse_label_list'
      security/smack/smackfs.c:1950: warning: Excess function parameter
      'private' description in 'smk_parse_label_list'
      security/smack/smackfs.c:1979: warning: Function parameter or member
      'list' not described in 'smk_destroy_label_list'
      security/smack/smackfs.c:1979: warning: Excess function parameter 'head'
      description in 'smk_destroy_label_list'
      security/smack/smackfs.c:2141: warning: Function parameter or member
      'count' not described in 'smk_read_logging'
      security/smack/smackfs.c:2141: warning: Excess function parameter 'cn'
      description in 'smk_read_logging'
      security/smack/smackfs.c:2278: warning: Function parameter or member
      'format' not described in 'smk_user_access'
      
      Correct them in this patch.
      Signed-off-by: NAlex Shi <alex.shi@linux.alibaba.com>
      Cc: Casey Schaufler <casey@schaufler-ca.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: linux-security-module@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      7da31b85
  23. 06 10月, 2020 1 次提交
  24. 23 9月, 2020 1 次提交
  25. 12 9月, 2020 3 次提交
  26. 24 8月, 2020 1 次提交
  27. 28 7月, 2020 2 次提交
  28. 15 7月, 2020 1 次提交
    • E
      Smack: fix use-after-free in smk_write_relabel_self() · beb4ee67
      Eric Biggers 提交于
      smk_write_relabel_self() frees memory from the task's credentials with
      no locking, which can easily cause a use-after-free because multiple
      tasks can share the same credentials structure.
      
      Fix this by using prepare_creds() and commit_creds() to correctly modify
      the task's credentials.
      
      Reproducer for "BUG: KASAN: use-after-free in smk_write_relabel_self":
      
      	#include <fcntl.h>
      	#include <pthread.h>
      	#include <unistd.h>
      
      	static void *thrproc(void *arg)
      	{
      		int fd = open("/sys/fs/smackfs/relabel-self", O_WRONLY);
      		for (;;) write(fd, "foo", 3);
      	}
      
      	int main()
      	{
      		pthread_t t;
      		pthread_create(&t, NULL, thrproc, NULL);
      		thrproc(NULL);
      	}
      
      Reported-by: syzbot+e6416dabb497a650da40@syzkaller.appspotmail.com
      Fixes: 38416e53 ("Smack: limited capability for changing process label")
      Cc: <stable@vger.kernel.org> # v4.4+
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      beb4ee67
  29. 21 5月, 2020 1 次提交
    • E
      exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds · b8bff599
      Eric W. Biederman 提交于
      Today security_bprm_set_creds has several implementations:
      apparmor_bprm_set_creds, cap_bprm_set_creds, selinux_bprm_set_creds,
      smack_bprm_set_creds, and tomoyo_bprm_set_creds.
      
      Except for cap_bprm_set_creds they all test bprm->called_set_creds and
      return immediately if it is true.  The function cap_bprm_set_creds
      ignores bprm->calld_sed_creds entirely.
      
      Create a new LSM hook security_bprm_creds_for_exec that is called just
      before prepare_binprm in __do_execve_file, resulting in a LSM hook
      that is called exactly once for the entire of exec.  Modify the bits
      of security_bprm_set_creds that only want to be called once per exec
      into security_bprm_creds_for_exec, leaving only cap_bprm_set_creds
      behind.
      
      Remove bprm->called_set_creds all of it's former users have been moved
      to security_bprm_creds_for_exec.
      
      Add or upate comments a appropriate to bring them up to date and
      to reflect this change.
      
      Link: https://lkml.kernel.org/r/87v9kszrzh.fsf_-_@x220.int.ebiederm.orgAcked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: Casey Schaufler <casey@schaufler-ca.com> # For the LSM and Smack bits
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      b8bff599
  30. 19 5月, 2020 2 次提交
    • D
      smack: Implement the watch_key and post_notification hooks · a8478a60
      David Howells 提交于
      Implement the watch_key security hook in Smack to make sure that a key
      grants the caller Read permission in order to set a watch on a key.
      
      Also implement the post_notification security hook to make sure that the
      notification source is granted Write permission by the watch queue.
      
      For the moment, the watch_devices security hook is left unimplemented as
      it's not obvious what the object should be since the queue is global and
      didn't previously exist.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      a8478a60
    • D
      keys: Make the KEY_NEED_* perms an enum rather than a mask · 8c0637e9
      David Howells 提交于
      Since the meaning of combining the KEY_NEED_* constants is undefined, make
      it so that you can't do that by turning them into an enum.
      
      The enum is also given some extra values to represent special
      circumstances, such as:
      
       (1) The '0' value is reserved and causes a warning to trap the parameter
           being unset.
      
       (2) The key is to be unlinked and we require no permissions on it, only
           the keyring, (this replaces the KEY_LOOKUP_FOR_UNLINK flag).
      
       (3) An override due to CAP_SYS_ADMIN.
      
       (4) An override due to an instantiation token being present.
      
       (5) The permissions check is being deferred to later key_permission()
           calls.
      
      The extra values give the opportunity for LSMs to audit these situations.
      
      [Note: This really needs overhauling so that lookup_user_key() tells
       key_task_permission() and the LSM what operation is being done and leaves
       it to those functions to decide how to map that onto the available
       permits.  However, I don't really want to make these change in the middle
       of the notifications patchset.]
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      cc: Paul Moore <paul@paul-moore.com>
      cc: Stephen Smalley <stephen.smalley.work@gmail.com>
      cc: Casey Schaufler <casey@schaufler-ca.com>
      cc: keyrings@vger.kernel.org
      cc: selinux@vger.kernel.org
      8c0637e9
  31. 12 5月, 2020 1 次提交