17 Dec, 2014

1 commit


13 Nov, 2014

2 commits


16 Oct, 2014

1 commit


15 Oct, 2014

1 commit

  • sb_finish_set_opts() can race with inode_free_security()
    when initializing inode security structures for inodes
    created prior to initial policy load or by the filesystem
    during ->mount(). This appears to have always been
    a possible race, but commit 3dc91d4 ("SELinux: Fix possible
    NULL pointer dereference in selinux_inode_permission()")
    made it more evident by immediately reusing the unioned
    list/rcu element of the inode security structure for call_rcu()
    upon an inode_free_security(). But the underlying issue
    was already present before that commit as a possible use-after-free
    of isec.

    Shivnandan Kumar reported the list corruption and proposed
    a patch to split the list and rcu elements out of the union
    as separate fields of the inode_security_struct so that setting
    the rcu element would not affect the list element. However,
    this would merely hide the issue and not truly fix the code.

    This patch instead moves up the deletion of the list entry
    prior to dropping the sbsec->isec_lock initially. Then,
    if the inode is dropped subsequently, there will be no further
    references to the isec.

    Reported-by: Shivnandan Kumar
    Signed-off-by: Stephen Smalley
    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Moore

    Stephen Smalley
     

12 Oct, 2014

1 commit

  • Pull security subsystem updates from James Morris.

    Mostly ima, selinux, smack and key handling updates.

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (65 commits)
    integrity: do zero padding of the key id
    KEYS: output last portion of fingerprint in /proc/keys
    KEYS: strip 'id:' from ca_keyid
    KEYS: use swapped SKID for performing partial matching
    KEYS: Restore partial ID matching functionality for asymmetric keys
    X.509: If available, use the raw subjKeyId to form the key description
    KEYS: handle error code encoded in pointer
    selinux: normalize audit log formatting
    selinux: cleanup error reporting in selinux_nlmsg_perm()
    KEYS: Check hex2bin()'s return when generating an asymmetric key ID
    ima: detect violations for mmaped files
    ima: fix race condition on ima_rdwr_violation_check and process_measurement
    ima: added ima_policy_flag variable
    ima: return an error code from ima_add_boot_aggregate()
    ima: provide 'ima_appraise=log' kernel option
    ima: move keyring initialization to ima_init()
    PKCS#7: Handle PKCS#7 messages that contain no X.509 certs
    PKCS#7: Better handling of unsupported crypto
    KEYS: Overhaul key identification when searching for asymmetric keys
    KEYS: Implement binary asymmetric key ID handling
    ...

    Linus Torvalds
     

23 Sep, 2014

2 commits


11 Sep, 2014

1 commit

  • While SELinux largely ignores namespaces, for good reason, there are
    some places where it needs to at least be aware of namespaces in order
    to function correctly. Network namespaces are one example. Basic
    awareness of network namespaces are necessary in order to match a
    network interface's index number to an actual network device.

    This patch corrects a problem with network interfaces added to a
    non-init namespace, and can be reproduced with the following commands:

    [NOTE: the NetLabel configuration is here only to active the dynamic
    networking controls ]

    # netlabelctl unlbl add default address:0.0.0.0/0 \
    label:system_u:object_r:unlabeled_t:s0
    # netlabelctl unlbl add default address:::/0 \
    label:system_u:object_r:unlabeled_t:s0
    # netlabelctl cipsov4 add pass doi:100 tags:1
    # netlabelctl map add domain:lspp_test_netlabel_t \
    protocol:cipsov4,100

    # ip link add type veth
    # ip netns add myns
    # ip link set veth1 netns myns
    # ip a add dev veth0 10.250.13.100/24
    # ip netns exec myns ip a add dev veth1 10.250.13.101/24
    # ip l set veth0 up
    # ip netns exec myns ip l set veth1 up

    # ping -c 1 10.250.13.101
    # ip netns exec myns ping -c 1 10.250.13.100

    Reported-by: Jiri Jaburek
    Signed-off-by: Paul Moore

    Paul Moore
     

10 Sep, 2014

1 commit


09 Sep, 2014

1 commit


03 Sep, 2014

1 commit


28 Aug, 2014

1 commit

  • If the callee SID is bounded by the caller SID, then allowing
    the transition to occur poses no risk of privilege escalation and we can
    therefore safely allow the transition to occur. Add this exemption
    for both the case where a transition was explicitly requested by the
    application and the case where an automatic transition is defined in
    policy.

    Signed-off-by: Stephen Smalley
    Reviewed-by: Andy Lutomirski
    Signed-off-by: Paul Moore

    Stephen Smalley
     

10 Aug, 2014

1 commit

  • Pull SElinux fixes from Paul Moore:
    "Two small patches to fix a couple of build warnings in SELinux and
    NetLabel. The patches are obvious enough that I don't think any
    additional explanation is necessary, but it basically boils down to
    the usual: I was stupid, and these patches fix some of the stupid.

    Both patches were posted earlier this week to the SELinux list, and
    that is where they sat as I didn't think there were noteworthy enough
    to go upstream at this point in time, but DaveM would rather see them
    upstream now so who am I to argue. As the patches are both very
    small"

    * 'stable-3.17' of git://git.infradead.org/users/pcmoore/selinux:
    selinux: remove unused variabled in the netport, netnode, and netif caches
    netlabel: fix the netlbl_catmap_setlong() dummy function

    Linus Torvalds
     

08 Aug, 2014

1 commit


06 Aug, 2014

1 commit


02 Aug, 2014

1 commit


01 Aug, 2014

2 commits

  • Historically the NetLabel LSM secattr catmap functions and data
    structures have had very long names which makes a mess of the NetLabel
    code and anyone who uses NetLabel. This patch renames the catmap
    functions and structures from "*_secattr_catmap_*" to just "*_catmap_*"
    which improves things greatly.

    There are no substantial code or logic changes in this patch.

    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     
  • The NetLabel secattr catmap functions, and the SELinux import/export
    glue routines, were broken in many horrible ways and the SELinux glue
    code fiddled with the NetLabel catmap structures in ways that we
    probably shouldn't allow. At some point this "worked", but that was
    likely due to a bit of dumb luck and sub-par testing (both inflicted
    by yours truly). This patch corrects these problems by basically
    gutting the code in favor of something less obtuse and restoring the
    NetLabel abstractions in the SELinux catmap glue code.

    Everything is working now, and if it decides to break itself in the
    future this code will be much easier to debug than the code it
    replaces.

    One noteworthy side effect of the changes is that it is no longer
    necessary to allocate a NetLabel catmap before calling one of the
    NetLabel APIs to set a bit in the catmap. NetLabel will automatically
    allocate the catmap nodes when needed, resulting in less allocations
    when the lowest bit is greater than 255 and less code in the LSMs.

    Cc: stable@vger.kernel.org
    Reported-by: Christian Evans
    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     

29 Jul, 2014

1 commit


28 Jul, 2014

1 commit

  • This reverts commit 4da6daf4d3df5a977e4623963f141a627fd2efce.

    Unfortunately, the commit in question caused problems with Bluetooth
    devices, specifically it caused them to get caught in the newly
    created BUG_ON() check. The AF_ALG problem still exists, but will be
    addressed in a future patch.

    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Moore

    Paul Moore
     

19 Jul, 2014

1 commit


17 Jul, 2014

1 commit


10 Jul, 2014

1 commit

  • The sock_graft() hook has special handling for AF_INET, AF_INET, and
    AF_UNIX sockets as those address families have special hooks which
    label the sock before it is attached its associated socket.
    Unfortunately, the sock_graft() hook was missing a default approach
    to labeling sockets which meant that any other address family which
    made use of connections or the accept() syscall would find the
    returned socket to be in an "unlabeled" state. This was recently
    demonstrated by the kcrypto/AF_ALG subsystem and the newly released
    cryptsetup package (cryptsetup v1.6.5 and later).

    This patch preserves the special handling in selinux_sock_graft(),
    but adds a default behavior - setting the sock's label equal to the
    associated socket - which resolves the problem with AF_ALG and
    presumably any other address family which makes use of accept().

    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Moore
    Tested-by: Milan Broz

    Paul Moore
     

27 Jun, 2014

1 commit

  • When flushing the AVC, such as during a policy load, the various
    network caches are also flushed, with each making a call to
    synchronize_net() which has shown to be expensive in some cases.
    This patch consolidates the network cache flushes into a single AVC
    callback which only calls synchronize_net() once for each AVC cache
    flush.

    Reported-by: Jaejyn Shin
    Signed-off-by: Paul Moore

    Paul Moore
     

24 Jun, 2014

1 commit

  • With the introduction of fair queued rwlock, recursive read_lock()
    may hang the offending process if there is a write_lock() somewhere
    in between.

    With recursive read_lock checking enabled, the following error was
    reported:

    =============================================
    [ INFO: possible recursive locking detected ]
    3.16.0-rc1 #2 Tainted: G E
    ---------------------------------------------
    load_policy/708 is trying to acquire lock:
    (policy_rwlock){.+.+..}, at: []
    security_genfs_sid+0x3a/0x170

    but task is already holding lock:
    (policy_rwlock){.+.+..}, at: []
    security_fs_use+0x2c/0x110

    other info that might help us debug this:
    Possible unsafe locking scenario:

    CPU0
    ----
    lock(policy_rwlock);
    lock(policy_rwlock);

    This patch fixes the occurrence of recursive read_lock() of
    policy_rwlock by adding a helper function __security_genfs_sid()
    which requires caller to take the lock before calling it. The
    security_fs_use() was then modified to call the new helper function.

    Signed-off-by: Waiman Long
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Waiman Long
     

20 Jun, 2014

2 commits


19 Jun, 2014

2 commits


18 Jun, 2014

2 commits


13 Jun, 2014

1 commit

  • Pull networking updates from David Miller:

    1) Seccomp BPF filters can now be JIT'd, from Alexei Starovoitov.

    2) Multiqueue support in xen-netback and xen-netfront, from Andrew J
    Benniston.

    3) Allow tweaking of aggregation settings in cdc_ncm driver, from Bjørn
    Mork.

    4) BPF now has a "random" opcode, from Chema Gonzalez.

    5) Add more BPF documentation and improve test framework, from Daniel
    Borkmann.

    6) Support TCP fastopen over ipv6, from Daniel Lee.

    7) Add software TSO helper functions and use them to support software
    TSO in mvneta and mv643xx_eth drivers. From Ezequiel Garcia.

    8) Support software TSO in fec driver too, from Nimrod Andy.

    9) Add Broadcom SYSTEMPORT driver, from Florian Fainelli.

    10) Handle broadcasts more gracefully over macvlan when there are large
    numbers of interfaces configured, from Herbert Xu.

    11) Allow more control over fwmark used for non-socket based responses,
    from Lorenzo Colitti.

    12) Do TCP congestion window limiting based upon measurements, from Neal
    Cardwell.

    13) Support busy polling in SCTP, from Neal Horman.

    14) Allow RSS key to be configured via ethtool, from Venkata Duvvuru.

    15) Bridge promisc mode handling improvements from Vlad Yasevich.

    16) Don't use inetpeer entries to implement ID generation any more, it
    performs poorly, from Eric Dumazet.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1522 commits)
    rtnetlink: fix userspace API breakage for iproute2 < v3.9.0
    tcp: fixing TLP's FIN recovery
    net: fec: Add software TSO support
    net: fec: Add Scatter/gather support
    net: fec: Increase buffer descriptor entry number
    net: fec: Factorize feature setting
    net: fec: Enable IP header hardware checksum
    net: fec: Factorize the .xmit transmit function
    bridge: fix compile error when compiling without IPv6 support
    bridge: fix smatch warning / potential null pointer dereference
    via-rhine: fix full-duplex with autoneg disable
    bnx2x: Enlarge the dorq threshold for VFs
    bnx2x: Check for UNDI in uncommon branch
    bnx2x: Fix 1G-baseT link
    bnx2x: Fix link for KR with swapped polarity lane
    sctp: Fix sk_ack_backlog wrap-around problem
    net/core: Add VF link state control policy
    net/fsl: xgmac_mdio is dependent on OF_MDIO
    net/fsl: Make xgmac_mdio read error message useful
    net_sched: drr: warn when qdisc is not work conserving
    ...

    Linus Torvalds
     

11 Jun, 2014

1 commit

  • Pull security layer updates from Serge Hallyn:
    "This is a merge of James Morris' security-next tree from 3.14 to
    yesterday's master, plus four patches from Paul Moore which are in
    linux-next, plus one patch from Mimi"

    * 'serge-next-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux-security:
    ima: audit log files opened with O_DIRECT flag
    selinux: conditionally reschedule in hashtab_insert while loading selinux policy
    selinux: conditionally reschedule in mls_convert_context while loading selinux policy
    selinux: reject setexeccon() on MNT_NOSUID applications with -EACCES
    selinux: Report permissive mode in avc: denied messages.
    Warning in scanf string typing
    Smack: Label cgroup files for systemd
    Smack: Verify read access on file open - v3
    security: Convert use of typedef ctl_table to struct ctl_table
    Smack: bidirectional UDS connect check
    Smack: Correctly remove SMACK64TRANSMUTE attribute
    SMACK: Fix handling value==NULL in post setxattr
    bugfix patch for SMACK
    Smack: adds smackfs/ptrace interface
    Smack: unify all ptrace accesses in the smack
    Smack: fix the subject/object order in smack_ptrace_traceme()
    Minor improvement of 'smack_sb_kern_mount'
    smack: fix key permission verification
    KEYS: Move the flags representing required permission to linux/key.h

    Linus Torvalds
     

04 Jun, 2014

4 commits

  • After silencing the sleeping warning in mls_convert_context() I started
    seeing similar traces from hashtab_insert. Do a cond_resched there too.

    Signed-off-by: Dave Jones
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Dave Jones
     
  • On a slow machine (with debugging enabled), upgrading selinux policy may take
    a considerable amount of time. Long enough that the softlockup detector
    gets triggered.

    The backtrace looks like this..

    > BUG: soft lockup - CPU#2 stuck for 23s! [load_policy:19045]
    > Call Trace:
    > [] symcmp+0xf/0x20
    > [] hashtab_search+0x47/0x80
    > [] mls_convert_context+0xdc/0x1c0
    > [] convert_context+0x378/0x460
    > [] ? security_context_to_sid_core+0x240/0x240
    > [] sidtab_map+0x45/0x80
    > [] security_load_policy+0x3ff/0x580
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? sched_clock_local+0x1d/0x80
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? __change_page_attr_set_clr+0x82a/0xa50
    > [] ? sched_clock_local+0x1d/0x80
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? __change_page_attr_set_clr+0x82a/0xa50
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? retint_restore_args+0xe/0xe
    > [] ? trace_hardirqs_on_caller+0xfd/0x1c0
    > [] ? trace_hardirqs_on_thunk+0x3a/0x3f
    > [] ? rcu_irq_exit+0x68/0xb0
    > [] ? retint_restore_args+0xe/0xe
    > [] sel_write_load+0xa7/0x770
    > [] ? vfs_write+0x1c3/0x200
    > [] ? security_file_permission+0x1e/0xa0
    > [] vfs_write+0xbb/0x200
    > [] ? fget_light+0x397/0x4b0
    > [] SyS_write+0x47/0xa0
    > [] tracesys+0xdd/0xe2

    Stephen Smalley suggested:

    > Maybe put a cond_resched() within the ebitmap_for_each_positive_bit()
    > loop in mls_convert_context()?

    That seems to do the trick. Tested by downgrading and re-upgrading selinux-policy-targeted.

    Signed-off-by: Dave Jones
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Dave Jones
     
  • We presently prevent processes from using setexecon() to set the
    security label of exec()'d processes when NO_NEW_PRIVS is enabled by
    returning an error; however, we silently ignore setexeccon() when
    exec()'ing from a nosuid mounted filesystem. This patch makes things
    a bit more consistent by returning an error in the setexeccon()/nosuid
    case.

    Signed-off-by: Paul Moore
    Acked-by: Andy Lutomirski
    Acked-by: Stephen Smalley

    Paul Moore
     
  • We cannot presently tell from an avc: denied message whether access was in
    fact denied or was allowed due to global or per-domain permissive mode.
    Add a permissive= field to the avc message to reflect this information.

    Signed-off-by: Stephen Smalley
    Acked-by: Eric Paris
    Signed-off-by: Paul Moore

    Stephen Smalley
     

16 May, 2014

2 commits

  • After silencing the sleeping warning in mls_convert_context() I started
    seeing similar traces from hashtab_insert. Do a cond_resched there too.

    Signed-off-by: Dave Jones
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Dave Jones
     
  • On a slow machine (with debugging enabled), upgrading selinux policy may take
    a considerable amount of time. Long enough that the softlockup detector
    gets triggered.

    The backtrace looks like this..

    > BUG: soft lockup - CPU#2 stuck for 23s! [load_policy:19045]
    > Call Trace:
    > [] symcmp+0xf/0x20
    > [] hashtab_search+0x47/0x80
    > [] mls_convert_context+0xdc/0x1c0
    > [] convert_context+0x378/0x460
    > [] ? security_context_to_sid_core+0x240/0x240
    > [] sidtab_map+0x45/0x80
    > [] security_load_policy+0x3ff/0x580
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? sched_clock_local+0x1d/0x80
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? __change_page_attr_set_clr+0x82a/0xa50
    > [] ? sched_clock_local+0x1d/0x80
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? __change_page_attr_set_clr+0x82a/0xa50
    > [] ? sched_clock_cpu+0xa8/0x100
    > [] ? retint_restore_args+0xe/0xe
    > [] ? trace_hardirqs_on_caller+0xfd/0x1c0
    > [] ? trace_hardirqs_on_thunk+0x3a/0x3f
    > [] ? rcu_irq_exit+0x68/0xb0
    > [] ? retint_restore_args+0xe/0xe
    > [] sel_write_load+0xa7/0x770
    > [] ? vfs_write+0x1c3/0x200
    > [] ? security_file_permission+0x1e/0xa0
    > [] vfs_write+0xbb/0x200
    > [] ? fget_light+0x397/0x4b0
    > [] SyS_write+0x47/0xa0
    > [] tracesys+0xdd/0xe2

    Stephen Smalley suggested:

    > Maybe put a cond_resched() within the ebitmap_for_each_positive_bit()
    > loop in mls_convert_context()?

    That seems to do the trick. Tested by downgrading and re-upgrading selinux-policy-targeted.

    Signed-off-by: Dave Jones
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Dave Jones