1. 29 2月, 2020 2 次提交
  2. 18 2月, 2020 2 次提交
  3. 08 2月, 2020 2 次提交
  4. 06 2月, 2020 3 次提交
    • O
      selinux: fix sidtab string cache locking · 39a706fb
      Ondrej Mosnacek 提交于
      Avoiding taking a lock in an IRQ context is not enough to prevent
      deadlocks, as discovered by syzbot:
      
      ===
      WARNING: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected
      5.5.0-syzkaller #0 Not tainted
      -----------------------------------------------------
      syz-executor.0/8927 [HC0[0]:SC0[2]:HE1:SE0] is trying to acquire:
      ffff888027c94098 (&(&s->cache_lock)->rlock){+.+.}, at: spin_lock include/linux/spinlock.h:338 [inline]
      ffff888027c94098 (&(&s->cache_lock)->rlock){+.+.}, at: sidtab_sid2str_put.part.0+0x36/0x880 security/selinux/ss/sidtab.c:533
      
      and this task is already holding:
      ffffffff898639b0 (&(&nf_conntrack_locks[i])->rlock){+.-.}, at: spin_lock include/linux/spinlock.h:338 [inline]
      ffffffff898639b0 (&(&nf_conntrack_locks[i])->rlock){+.-.}, at: nf_conntrack_lock+0x17/0x70 net/netfilter/nf_conntrack_core.c:91
      which would create a new lock dependency:
       (&(&nf_conntrack_locks[i])->rlock){+.-.} -> (&(&s->cache_lock)->rlock){+.+.}
      
      but this new dependency connects a SOFTIRQ-irq-safe lock:
       (&(&nf_conntrack_locks[i])->rlock){+.-.}
      
      [...]
      
      other info that might help us debug this:
      
       Possible interrupt unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(&(&s->cache_lock)->rlock);
                                     local_irq_disable();
                                     lock(&(&nf_conntrack_locks[i])->rlock);
                                     lock(&(&s->cache_lock)->rlock);
        <Interrupt>
          lock(&(&nf_conntrack_locks[i])->rlock);
      
       *** DEADLOCK ***
      [...]
      ===
      
      Fix this by simply locking with irqsave/irqrestore and stop giving up on
      !in_task(). It makes the locking a bit slower, but it shouldn't make a
      big difference in real workloads. Under the scenario from [1] (only
      cache hits) it only increased the runtime overhead from the
      security_secid_to_secctx() function from ~2% to ~3% (it was ~5-65%
      before introducing the cache).
      
      [1] https://bugzilla.redhat.com/show_bug.cgi?id=1733259
      
      Fixes: d97bd23c ("selinux: cache the SID -> context string translation")
      Reported-by: syzbot+61cba5033e2072d61806@syzkaller.appspotmail.com
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      39a706fb
    • H
      selinux: fix typo in filesystem name · a20456ae
      Hridya Valsaraju 提交于
      Correct the filesystem name to "binder" to enable genfscon per-file
      labelling for binderfs.
      
      Fixes: 7a4b5194 ("selinux: allow per-file labelling for binderfs")
      Signed-off-by: NHridya Valsaraju <hridya@google.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      [PM: slight style changes to the subj/description]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      a20456ae
    • C
      broken ping to ipv6 linklocal addresses on debian buster · 87fbfffc
      Casey Schaufler 提交于
      I am seeing ping failures to IPv6 linklocal addresses with Debian
      buster. Easiest example to reproduce is:
      
      $ ping -c1 -w1 ff02::1%eth1
      connect: Invalid argument
      
      $ ping -c1 -w1 ff02::1%eth1
      PING ff02::01%eth1(ff02::1%eth1) 56 data bytes
      64 bytes from fe80::e0:f9ff:fe0c:37%eth1: icmp_seq=1 ttl=64 time=0.059 ms
      
      git bisect traced the failure to
      commit b9ef5513 ("smack: Check address length before reading address family")
      
      Arguably ping is being stupid since the buster version is not setting
      the address family properly (ping on stretch for example does):
      
      $ strace -e connect ping6 -c1 -w1 ff02::1%eth1
      connect(5, {sa_family=AF_UNSPEC,
      sa_data="\4\1\0\0\0\0\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\1\3\0\0\0"}, 28)
      = -1 EINVAL (Invalid argument)
      
      but the command works fine on kernels prior to this commit, so this is
      breakage which goes against the Linux paradigm of "don't break userspace"
      
      Cc: stable@vger.kernel.org
      Reported-by: NDavid Ahern <dsahern@gmail.com>
      Suggested-by: NTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      
       security/smack/smack_lsm.c | 41 +++++++++++++++++++----------------------
       1 file changed, 19 insertions(+), 22 deletions(-)
      87fbfffc
  5. 28 1月, 2020 1 次提交
  6. 23 1月, 2020 7 次提交
  7. 20 1月, 2020 1 次提交
    • S
      selinux: fix regression introduced by move_mount(2) syscall · 98aa0034
      Stephen Smalley 提交于
      commit 2db154b3 ("vfs: syscall: Add move_mount(2) to move mounts around")
      introduced a new move_mount(2) system call and a corresponding new LSM
      security_move_mount hook but did not implement this hook for any existing
      LSM.  This creates a regression for SELinux with respect to consistent
      checking of mounts; the existing selinux_mount hook checks mounton
      permission to the mount point path.  Provide a SELinux hook
      implementation for move_mount that applies this same check for
      consistency.  In the future we may wish to add a new move_mount
      filesystem permission and check as well, but this addresses
      the immediate regression.
      
      Fixes: 2db154b3 ("vfs: syscall: Add move_mount(2) to move mounts around")
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Reviewed-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      98aa0034
  8. 17 1月, 2020 4 次提交
    • O
      selinux: do not allocate ancillary buffer on first load · dd89b9d9
      Ondrej Mosnacek 提交于
      In security_load_policy(), we can defer allocating the newpolicydb
      ancillary array to after checking state->initialized, thereby avoiding
      the pointless allocation when loading policy the first time.
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      [PM: merged portions by hand]
      Reviewed-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      dd89b9d9
    • P
      selinux: remove redundant allocation and helper functions · cb89e246
      Paul Moore 提交于
      This patch removes the inode, file, and superblock security blob
      allocation functions and moves the associated code into the
      respective LSM hooks.  This patch also removes the inode_doinit()
      function as it was a trivial wrapper around
      inode_doinit_with_dentry() and called from one location in the code.
      Reviewed-by: NCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      cb89e246
    • H
      selinux: remove redundant selinux_nlmsg_perm · df4779b5
      Huaisheng Ye 提交于
      selinux_nlmsg_perm is used for only by selinux_netlink_send. Remove
      the redundant function to simplify the code.
      
      Fix a typo by suggestion from Stephen.
      Signed-off-by: NHuaisheng Ye <yehs1@lenovo.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      df4779b5
    • O
      selinux: fix wrong buffer types in policydb.c · ae3d8c2e
      Ondrej Mosnacek 提交于
      Two places used u32 where there should have been __le32.
      
      Fixes sparse warnings:
        CHECK   [...]/security/selinux/ss/services.c
      [...]/security/selinux/ss/policydb.c:2669:16: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2669:16:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2669:16:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2674:24: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2674:24:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2674:24:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2675:24: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2675:24:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2675:24:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2676:24: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2676:24:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2676:24:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2681:32: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2681:32:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2681:32:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2701:16: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2701:16:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2701:16:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2706:24: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2706:24:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2706:24:    got restricted __le32 [usertype]
      [...]/security/selinux/ss/policydb.c:2707:24: warning: incorrect type in assignment (different base types)
      [...]/security/selinux/ss/policydb.c:2707:24:    expected unsigned int
      [...]/security/selinux/ss/policydb.c:2707:24:    got restricted __le32 [usertype]
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Reviewed-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      ae3d8c2e
  9. 15 1月, 2020 1 次提交
  10. 11 1月, 2020 6 次提交
  11. 10 1月, 2020 2 次提交
  12. 08 1月, 2020 1 次提交
    • S
      Documentation,selinux: fix references to old selinuxfs mount point · d41415eb
      Stephen Smalley 提交于
      selinuxfs was originally mounted on /selinux, and various docs and
      kconfig help texts referred to nodes under it.  In Linux 3.0,
      /sys/fs/selinux was introduced as the preferred mount point for selinuxfs.
      Fix all the old references to /selinux/ to /sys/fs/selinux/.
      While we are there, update the description of the selinux boot parameter
      to reflect the fact that the default value is always 1 since
      commit be6ec88f ("selinux: Remove SECURITY_SELINUX_BOOTPARAM_VALUE")
      and drop discussion of runtime disable since it is deprecated.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      d41415eb
  13. 07 1月, 2020 3 次提交
  14. 05 1月, 2020 1 次提交
  15. 02 1月, 2020 3 次提交
  16. 25 12月, 2019 1 次提交
    • Y
      selinux: remove set but not used variable 'sidtab' · f1268534
      YueHaibing 提交于
      security/selinux/ss/services.c: In function security_port_sid:
      security/selinux/ss/services.c:2346:17: warning: variable sidtab set but not used [-Wunused-but-set-variable]
      security/selinux/ss/services.c: In function security_ib_endport_sid:
      security/selinux/ss/services.c:2435:17: warning: variable sidtab set but not used [-Wunused-but-set-variable]
      security/selinux/ss/services.c: In function security_netif_sid:
      security/selinux/ss/services.c:2480:17: warning: variable sidtab set but not used [-Wunused-but-set-variable]
      security/selinux/ss/services.c: In function security_fs_use:
      security/selinux/ss/services.c:2831:17: warning: variable sidtab set but not used [-Wunused-but-set-variable]
      
      Since commit 66f8e2f0 ("selinux: sidtab reverse lookup hash table")
      'sidtab' is not used any more, so remove it.
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      f1268534