27 Jul, 2016

1 commit

  • Pull crypto updates from Herbert Xu:
    "Here is the crypto update for 4.8:

    API:
    - first part of skcipher low-level conversions
    - add KPP (Key-agreement Protocol Primitives) interface.

    Algorithms:
    - fix IPsec/cryptd reordering issues that affects aesni
    - RSA no longer does explicit leading zero removal
    - add SHA3
    - add DH
    - add ECDH
    - improve DRBG performance by not doing CTR by hand

    Drivers:
    - add x86 AVX2 multibuffer SHA256/512
    - add POWER8 optimised crc32c
    - add xts support to vmx
    - add DH support to qat
    - add RSA support to caam
    - add Layerscape support to caam
    - add SEC1 AEAD support to talitos
    - improve performance by chaining requests in marvell/cesa
    - add support for Araneus Alea I USB RNG
    - add support for Broadcom BCM5301 RNG
    - add support for Amlogic Meson RNG
    - add support Broadcom NSP SoC RNG"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (180 commits)
    crypto: vmx - Fix aes_p8_xts_decrypt build failure
    crypto: vmx - Ignore generated files
    crypto: vmx - Adding support for XTS
    crypto: vmx - Adding asm subroutines for XTS
    crypto: skcipher - add comment for skcipher_alg->base
    crypto: testmgr - Print akcipher algorithm name
    crypto: marvell - Fix wrong flag used for GFP in mv_cesa_dma_add_iv_op
    crypto: nx - off by one bug in nx_of_update_msc()
    crypto: rsa-pkcs1pad - fix rsa-pkcs1pad request struct
    crypto: scatterwalk - Inline start/map/done
    crypto: scatterwalk - Remove unnecessary BUG in scatterwalk_start
    crypto: scatterwalk - Remove unnecessary advance in scatterwalk_pagedone
    crypto: scatterwalk - Fix test in scatterwalk_done
    crypto: api - Optimise away crypto_yield when hard preemption is on
    crypto: scatterwalk - add no-copy support to copychunks
    crypto: scatterwalk - Remove scatterwalk_bytes_sglen
    crypto: omap - Stop using crypto scatterwalk_bytes_sglen
    crypto: skcipher - Remove top-level givcipher interface
    crypto: user - Remove crypto_lookup_skcipher call
    crypto: cts - Convert to skcipher
    ...

    Linus Torvalds
     

08 Jul, 2016

1 commit

  • When proc_pid_attr_write() was changed to use memdup_user apparmor's
    (interface violating) assumption that the setprocattr buffer was always
    a single page was violated.

    The size test is not strictly speaking needed as proc_pid_attr_write()
    will reject anything larger, but for the sake of robustness we can keep
    it in.

    SMACK and SELinux look safe to me, but somebody else should probably
    have a look just in case.

    Based on original patch from Vegard Nossum
    modified for the case that apparmor provides null termination.

    Fixes: bb646cdb12e75d82258c2f2e7746d5952d3e321a
    Reported-by: Vegard Nossum
    Cc: Al Viro
    Cc: John Johansen
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Eric Paris
    Cc: Casey Schaufler
    Cc: stable@kernel.org
    Signed-off-by: John Johansen
    Reviewed-by: Tyler Hicks
    Signed-off-by: James Morris

    Vegard Nossum
     

24 Jun, 2016

1 commit


17 Jun, 2016

1 commit

  • If __key_link_begin() failed then "edit" would be uninitialized. I've
    added a check to fix that.

    This allows a random user to crash the kernel, though it's quite
    difficult to achieve. There are three ways it can be done as the user
    would have to cause an error to occur in __key_link():

    (1) Cause the kernel to run out of memory. In practice, this is difficult
    to achieve without ENOMEM cropping up elsewhere and aborting the
    attempt.

    (2) Revoke the destination keyring between the keyring ID being looked up
    and it being tested for revocation. In practice, this is difficult to
    time correctly because the KEYCTL_REJECT function can only be used
    from the request-key upcall process. Further, users can only make use
    of what's in /sbin/request-key.conf, though this does including a
    rejection debugging test - which means that the destination keyring
    has to be the caller's session keyring in practice.

    (3) Have just enough key quota available to create a key, a new session
    keyring for the upcall and a link in the session keyring, but not then
    sufficient quota to create a link in the nominated destination keyring
    so that it fails with EDQUOT.

    The bug can be triggered using option (3) above using something like the
    following:

    echo 80 >/proc/sys/kernel/keys/root_maxbytes
    keyctl request2 user debug:fred negate @t

    The above sets the quota to something much lower (80) to make the bug
    easier to trigger, but this is dependent on the system. Note also that
    the name of the keyring created contains a random number that may be
    between 1 and 10 characters in size, so may throw the test off by
    changing the amount of quota used.

    Assuming the failure occurs, something like the following will be seen:

    kfree_debugcheck: out of range ptr 6b6b6b6b6b6b6b68h
    ------------[ cut here ]------------
    kernel BUG at ../mm/slab.c:2821!
    ...
    RIP: 0010:[] kfree_debugcheck+0x20/0x25
    RSP: 0018:ffff8804014a7de8 EFLAGS: 00010092
    RAX: 0000000000000034 RBX: 6b6b6b6b6b6b6b68 RCX: 0000000000000000
    RDX: 0000000000040001 RSI: 00000000000000f6 RDI: 0000000000000300
    RBP: ffff8804014a7df0 R08: 0000000000000001 R09: 0000000000000000
    R10: ffff8804014a7e68 R11: 0000000000000054 R12: 0000000000000202
    R13: ffffffff81318a66 R14: 0000000000000000 R15: 0000000000000001
    ...
    Call Trace:
    kfree+0xde/0x1bc
    assoc_array_cancel_edit+0x1f/0x36
    __key_link_end+0x55/0x63
    key_reject_and_link+0x124/0x155
    keyctl_reject_key+0xb6/0xe0
    keyctl_negate_key+0x10/0x12
    SyS_keyctl+0x9f/0xe7
    do_syscall_64+0x63/0x13a
    entry_SYSCALL64_slow_path+0x25/0x25

    Fixes: f70e2e06196a ('KEYS: Do preallocation for __key_link()')
    Signed-off-by: Dan Carpenter
    Signed-off-by: David Howells
    cc: stable@vger.kernel.org
    Signed-off-by: Linus Torvalds

    Dan Carpenter
     

03 Jun, 2016

1 commit

  • The values computed during Diffie-Hellman key exchange are often used
    in combination with key derivation functions to create cryptographic
    keys. Add a placeholder for a later implementation to configure a
    key derivation function that will transform the Diffie-Hellman
    result returned by the KEYCTL_DH_COMPUTE command.

    [This patch was stripped down from a patch produced by Mat Martineau that
    had a bug in the compat code - so for the moment Stephan's patch simply
    requires that the placeholder argument must be NULL]

    Original-signed-off-by: Mat Martineau
    Signed-off-by: Stephan Mueller
    Signed-off-by: David Howells
    Signed-off-by: James Morris

    Stephan Mueller
     

28 May, 2016

2 commits

  • Pull vfs fixes from Al Viro:
    "Followups to the parallel lookup work:

    - update docs

    - restore killability of the places that used to take ->i_mutex
    killably now that we have down_write_killable() merged

    - Additionally, it turns out that I missed a prerequisite for
    security_d_instantiate() stuff - ->getxattr() wasn't the only thing
    that could be called before dentry is attached to inode; with smack
    we needed the same treatment applied to ->setxattr() as well"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    switch ->setxattr() to passing dentry and inode separately
    switch xattr_handler->set() to passing dentry and inode separately
    restore killability of old mutex_lock_killable(&inode->i_mutex) users
    add down_write_killable_nested()
    update D/f/directory-locking

    Linus Torvalds
     
  • smack ->d_instantiate() uses ->setxattr(), so to be able to call it before
    we'd hashed the new dentry and attached it to inode, we need ->setxattr()
    instances getting the inode as an explicit argument rather than obtaining
    it from dentry.

    Similar change for ->getxattr() had been done in commit ce23e64. Unlike
    ->getxattr() (which is used by both selinux and smack instances of
    ->d_instantiate()) ->setxattr() is used only by smack one and unfortunately
    it got missed back then.

    Reported-by: Seung-Woo Kim
    Tested-by: Casey Schaufler
    Signed-off-by: Al Viro

    Al Viro
     

26 May, 2016

1 commit

  • Commit 8a56038c2aef ("Yama: consolidate error reporting") causes lockups
    when someone hits a Yama denial. Call chain:

    process_vm_readv -> process_vm_rw -> process_vm_rw_core -> mm_access
    -> ptrace_may_access
    task_lock(...) is taken
    __ptrace_may_access -> security_ptrace_access_check
    -> yama_ptrace_access_check -> report_access -> kstrdup_quotable_cmdline
    -> get_cmdline -> access_process_vm -> get_task_mm
    task_lock(...) is taken again

    task_lock(p) just calls spin_lock(&p->alloc_lock), so at this point,
    spin_lock() is called on a lock that is already held by the current
    process.

    Also: Since the alloc_lock is a spinlock, sleeping inside
    security_ptrace_access_check hooks is probably not allowed at all? So it's
    not even possible to print the cmdline from in there because that might
    involve paging in userspace memory.

    It would be tempting to rewrite ptrace_may_access() to drop the alloc_lock
    before calling the LSM, but even then, ptrace_may_access() itself might be
    called from various contexts in which you're not allowed to sleep; for
    example, as far as I understand, to be able to hold a reference to another
    task, usually an RCU read lock will be taken (see e.g. kcmp() and
    get_robust_list()), so that also prohibits sleeping. (And using e.g. FUSE,
    a user can cause pagefault handling to take arbitrary amounts of time -
    see https://bugs.chromium.org/p/project-zero/issues/detail?id=808.)

    Therefore, AFAIK, in order to print the name of a process below
    security_ptrace_access_check(), you'd have to either grab a reference to
    the mm_struct and defer the access violation reporting or just use the
    "comm" value that's stored in kernelspace and accessible without big
    complications. (Or you could try to use some kind of atomic remote VM
    access that fails if the memory isn't paged in, similar to
    copy_from_user_inatomic(), and if necessary fall back to comm, but
    that'd be kind of ugly because the comm/cmdline choice would look
    pretty random to the user.)

    Fix it by deferring reporting of the access violation until current
    exits kernelspace the next time.

    v2: Don't oops on PTRACE_TRACEME, call report_access under
    task_lock(current). Also fix nonsensical comment. And don't use
    GPF_ATOMIC for memory allocation with no locks held.
    This patch is tested both for ptrace attach and ptrace traceme.

    Fixes: 8a56038c2aef ("Yama: consolidate error reporting")
    Signed-off-by: Jann Horn
    Acked-by: Kees Cook
    Signed-off-by: James Morris

    Jann Horn
     

21 May, 2016

1 commit


20 May, 2016

1 commit

  • Pull security subsystem updates from James Morris:
    "Highlights:

    - A new LSM, "LoadPin", from Kees Cook is added, which allows forcing
    of modules and firmware to be loaded from a specific device (this
    is from ChromeOS, where the device as a whole is verified
    cryptographically via dm-verity).

    This is disabled by default but can be configured to be enabled by
    default (don't do this if you don't know what you're doing).

    - Keys: allow authentication data to be stored in an asymmetric key.
    Lots of general fixes and updates.

    - SELinux: add restrictions for loading of kernel modules via
    finit_module(). Distinguish non-init user namespace capability
    checks. Apply execstack check on thread stacks"

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (48 commits)
    LSM: LoadPin: provide enablement CONFIG
    Yama: use atomic allocations when reporting
    seccomp: Fix comment typo
    ima: add support for creating files using the mknodat syscall
    ima: fix ima_inode_post_setattr
    vfs: forbid write access when reading a file into memory
    fs: fix over-zealous use of "const"
    selinux: apply execstack check on thread stacks
    selinux: distinguish non-init user namespace capability checks
    LSM: LoadPin for kernel file loading restrictions
    fs: define a string representation of the kernel_read_file_id enumeration
    Yama: consolidate error reporting
    string_helpers: add kstrdup_quotable_file
    string_helpers: add kstrdup_quotable_cmdline
    string_helpers: add kstrdup_quotable
    selinux: check ss_initialized before revalidating an inode label
    selinux: delay inode label lookup as long as possible
    selinux: don't revalidate an inode's label when explicitly setting it
    selinux: Change bool variable name to index.
    KEYS: Add KEYCTL_DH_COMPUTE command
    ...

    Linus Torvalds
     

18 May, 2016

4 commits

  • Pull networking updates from David Miller:
    "Highlights:

    1) Support SPI based w5100 devices, from Akinobu Mita.

    2) Partial Segmentation Offload, from Alexander Duyck.

    3) Add GMAC4 support to stmmac driver, from Alexandre TORGUE.

    4) Allow cls_flower stats offload, from Amir Vadai.

    5) Implement bpf blinding, from Daniel Borkmann.

    6) Optimize _ASYNC_ bit twiddling on sockets, unless the socket is
    actually using FASYNC these atomics are superfluous. From Eric
    Dumazet.

    7) Run TCP more preemptibly, also from Eric Dumazet.

    8) Support LED blinking, EEPROM dumps, and rxvlan offloading in mlx5e
    driver, from Gal Pressman.

    9) Allow creating ppp devices via rtnetlink, from Guillaume Nault.

    10) Improve BPF usage documentation, from Jesper Dangaard Brouer.

    11) Support tunneling offloads in qed, from Manish Chopra.

    12) aRFS offloading in mlx5e, from Maor Gottlieb.

    13) Add RFS and RPS support to SCTP protocol, from Marcelo Ricardo
    Leitner.

    14) Add MSG_EOR support to TCP, this allows controlling packet
    coalescing on application record boundaries for more accurate
    socket timestamp sampling. From Martin KaFai Lau.

    15) Fix alignment of 64-bit netlink attributes across the board, from
    Nicolas Dichtel.

    16) Per-vlan stats in bridging, from Nikolay Aleksandrov.

    17) Several conversions of drivers to ethtool ksettings, from Philippe
    Reynes.

    18) Checksum neutral ILA in ipv6, from Tom Herbert.

    19) Factorize all of the various marvell dsa drivers into one, from
    Vivien Didelot

    20) Add VF support to qed driver, from Yuval Mintz"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1649 commits)
    Revert "phy dp83867: Fix compilation with CONFIG_OF_MDIO=m"
    Revert "phy dp83867: Make rgmii parameters optional"
    r8169: default to 64-bit DMA on recent PCIe chips
    phy dp83867: Make rgmii parameters optional
    phy dp83867: Fix compilation with CONFIG_OF_MDIO=m
    bpf: arm64: remove callee-save registers use for tmp registers
    asix: Fix offset calculation in asix_rx_fixup() causing slow transmissions
    switchdev: pass pointer to fib_info instead of copy
    net_sched: close another race condition in tcf_mirred_release()
    tipc: fix nametable publication field in nl compat
    drivers: net: Don't print unpopulated net_device name
    qed: add support for dcbx.
    ravb: Add missing free_irq() calls to ravb_close()
    qed: Remove a stray tab
    net: ethernet: fec-mpc52xx: use phy_ethtool_{get|set}_link_ksettings
    net: ethernet: fec-mpc52xx: use phydev from struct net_device
    bpf, doc: fix typo on bpf_asm descriptions
    stmmac: hardware TX COE doesn't work when force_thresh_dma_mode is set
    net: ethernet: fs-enet: use phy_ethtool_{get|set}_link_ksettings
    net: ethernet: fs-enet: use phydev from struct net_device
    ...

    Linus Torvalds
     
  • Pull 'struct path' constification update from Al Viro:
    "'struct path' is passed by reference to a bunch of Linux security
    methods; in theory, there's nothing to stop them from modifying the
    damn thing and LSM community being what it is, sooner or later some
    enterprising soul is going to decide that it's a good idea.

    Let's remove the temptation and constify all of those..."

    * 'work.const-path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    constify ima_d_path()
    constify security_sb_pivotroot()
    constify security_path_chroot()
    constify security_path_{link,rename}
    apparmor: remove useless checks for NULL ->mnt
    constify security_path_{mkdir,mknod,symlink}
    constify security_path_{unlink,rmdir}
    apparmor: constify common_perm_...()
    apparmor: constify aa_path_link()
    apparmor: new helper - common_path_perm()
    constify chmod_common/security_path_chmod
    constify security_sb_mount()
    constify chown_common/security_path_chown
    tomoyo: constify assorted struct path *
    apparmor_path_truncate(): path->mnt is never NULL
    constify vfs_truncate()
    constify security_path_truncate()
    [apparmor] constify struct path * in a bunch of helpers

    Linus Torvalds
     
  • Pull parallel filesystem directory handling update from Al Viro.

    This is the main parallel directory work by Al that makes the vfs layer
    able to do lookup and readdir in parallel within a single directory.
    That's a big change, since this used to be all protected by the
    directory inode mutex.

    The inode mutex is replaced by an rwsem, and serialization of lookups of
    a single name is done by a "in-progress" dentry marker.

    The series begins with xattr cleanups, and then ends with switching
    filesystems over to actually doing the readdir in parallel (switching to
    the "iterate_shared()" that only takes the read lock).

    A more detailed explanation of the process from Al Viro:
    "The xattr work starts with some acl fixes, then switches ->getxattr to
    passing inode and dentry separately. This is the point where the
    things start to get tricky - that got merged into the very beginning
    of the -rc3-based #work.lookups, to allow untangling the
    security_d_instantiate() mess. The xattr work itself proceeds to
    switch a lot of filesystems to generic_...xattr(); no complications
    there.

    After that initial xattr work, the series then does the following:

    - untangle security_d_instantiate()

    - convert a bunch of open-coded lookup_one_len_unlocked() to calls of
    that thing; one such place (in overlayfs) actually yields a trivial
    conflict with overlayfs fixes later in the cycle - overlayfs ended
    up switching to a variant of lookup_one_len_unlocked() sans the
    permission checks. I would've dropped that commit (it gets
    overridden on merge from #ovl-fixes in #for-next; proper resolution
    is to use the variant in mainline fs/overlayfs/super.c), but I
    didn't want to rebase the damn thing - it was fairly late in the
    cycle...

    - some filesystems had managed to depend on lookup/lookup exclusion
    for *fs-internal* data structures in a way that would break if we
    relaxed the VFS exclusion. Fixing hadn't been hard, fortunately.

    - core of that series - parallel lookup machinery, replacing
    ->i_mutex with rwsem, making lookup_slow() take it only shared. At
    that point lookups happen in parallel; lookups on the same name
    wait for the in-progress one to be done with that dentry.

    Surprisingly little code, at that - almost all of it is in
    fs/dcache.c, with fs/namei.c changes limited to lookup_slow() -
    making it use the new primitive and actually switching to locking
    shared.

    - parallel readdir stuff - first of all, we provide the exclusion on
    per-struct file basis, same as we do for read() vs lseek() for
    regular files. That takes care of most of the needed exclusion in
    readdir/readdir; however, these guys are trickier than lookups, so
    I went for switching them one-by-one. To do that, a new method
    '->iterate_shared()' is added and filesystems are switched to it
    as they are either confirmed to be OK with shared lock on directory
    or fixed to be OK with that. I hope to kill the original method
    come next cycle (almost all in-tree filesystems are switched
    already), but it's still not quite finished.

    - several filesystems get switched to parallel readdir. The
    interesting part here is dealing with dcache preseeding by readdir;
    that needs minor adjustment to be safe with directory locked only
    shared.

    Most of the filesystems doing that got switched to in those
    commits. Important exception: NFS. Turns out that NFS folks, with
    their, er, insistence on VFS getting the fuck out of the way of the
    Smart Filesystem Code That Knows How And What To Lock(tm) have
    grown the locking of their own. They had their own homegrown
    rwsem, with lookup/readdir/atomic_open being *writers* (sillyunlink
    is the reader there). Of course, with VFS getting the fuck out of
    the way, as requested, the actual smarts of the smart filesystem
    code etc. had become exposed...

    - do_last/lookup_open/atomic_open cleanups. As the result, open()
    without O_CREAT locks the directory only shared. Including the
    ->atomic_open() case. Backmerge from #for-linus in the middle of
    that - atomic_open() fix got brought in.

    - then comes NFS switch to saner (VFS-based ;-) locking, killing the
    homegrown "lookup and readdir are writers" kinda-sorta rwsem. All
    exclusion for sillyunlink/lookup is done by the parallel lookups
    mechanism. Exclusion between sillyunlink and rmdir is a real rwsem
    now - rmdir being the writer.

    Result: NFS lookups/readdirs/O_CREAT-less opens happen in parallel
    now.

    - the rest of the series consists of switching a lot of filesystems
    to parallel readdir; in a lot of cases ->llseek() gets simplified
    as well. One backmerge in there (again, #for-linus - rockridge
    fix)"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (74 commits)
    ext4: switch to ->iterate_shared()
    hfs: switch to ->iterate_shared()
    hfsplus: switch to ->iterate_shared()
    hostfs: switch to ->iterate_shared()
    hpfs: switch to ->iterate_shared()
    hpfs: handle allocation failures in hpfs_add_pos()
    gfs2: switch to ->iterate_shared()
    f2fs: switch to ->iterate_shared()
    afs: switch to ->iterate_shared()
    befs: switch to ->iterate_shared()
    befs: constify stuff a bit
    isofs: switch to ->iterate_shared()
    get_acorn_filename(): deobfuscate a bit
    btrfs: switch to ->iterate_shared()
    logfs: no need to lock directory in lseek
    switch ecryptfs to ->iterate_shared
    9p: switch to ->iterate_shared()
    fat: switch to ->iterate_shared()
    romfs, squashfs: switch to ->iterate_shared()
    more trivial ->iterate_shared conversions
    ...

    Linus Torvalds
     
  • Pull timer updates from Thomas Gleixner:
    "A rather small set of patches from the timer departement:

    - Some more y2038 work
    - Yet another new clocksource driver
    - The usual set of small fixes, cleanups and enhancements"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    clocksource/drivers/tegra: Remove unused suspend/resume code
    clockevents/driversi/mps2: add MPS2 Timer driver
    dt-bindings: document the MPS2 timer bindings
    clocksource/drivers/mtk_timer: Add __init attribute
    clockevents/drivers/dw_apb_timer: Implement ->set_state_oneshot_stopped()
    time: Introduce do_sys_settimeofday64()
    security: Introduce security_settime64()
    clocksource: Add missing include of of.h.

    Linus Torvalds
     

17 May, 2016

2 commits

  • Instead of being enabled by default when SECURITY_LOADPIN is selected,
    provide an additional (default off) config to determine the boot time
    behavior. As before, the "loadpin.enabled=0/1" kernel parameter remains
    available.

    Suggested-by: James Morris
    Signed-off-by: Kees Cook
    Signed-off-by: James Morris

    Kees Cook
     
  • Backmerge to resolve a conflict in ovl_lookup_real();
    "ovl_lookup_real(): use lookup_one_len_unlocked()" instead,
    but it was too late in the cycle to rebase.

    Al Viro
     

10 May, 2016

1 commit


06 May, 2016

2 commits


05 May, 2016

2 commits

  • Access reporting often happens from atomic contexes. Avoid
    lockups when allocating memory for command lines.

    Fixes: 8a56038c2ae ("Yama: consolidate error reporting")
    Signed-off-by: Sasha Levin

    Sasha Levin
     
  • Here's a set of patches that changes how certificates/keys are determined
    to be trusted. That's currently a two-step process:

    (1) Up until recently, when an X.509 certificate was parsed - no matter
    the source - it was judged against the keys in .system_keyring,
    assuming those keys to be trusted if they have KEY_FLAG_TRUSTED set
    upon them.

    This has just been changed such that any key in the .ima_mok keyring,
    if configured, may also be used to judge the trustworthiness of a new
    certificate, whether or not the .ima_mok keyring is meant to be
    consulted for whatever process is being undertaken.

    If a certificate is determined to be trustworthy, KEY_FLAG_TRUSTED
    will be set upon a key it is loaded into (if it is loaded into one),
    no matter what the key is going to be loaded for.

    (2) If an X.509 certificate is loaded into a key, then that key - if
    KEY_FLAG_TRUSTED gets set upon it - can be linked into any keyring
    with KEY_FLAG_TRUSTED_ONLY set upon it. This was meant to be the
    system keyring only, but has been extended to various IMA keyrings.
    A user can at will link any key marked KEY_FLAG_TRUSTED into any
    keyring marked KEY_FLAG_TRUSTED_ONLY if the relevant permissions masks
    permit it.

    These patches change that:

    (1) Trust becomes a matter of consulting the ring of trusted keys supplied
    when the trust is evaluated only.

    (2) Every keyring can be supplied with its own manager function to
    restrict what may be added to that keyring. This is called whenever a
    key is to be linked into the keyring to guard against a key being
    created in one keyring and then linked across.

    This function is supplied with the keyring and the key type and
    payload[*] of the key being linked in for use in its evaluation. It
    is permitted to use other data also, such as the contents of other
    keyrings such as the system keyrings.

    [*] The type and payload are supplied instead of a key because as an
    optimisation this function may be called whilst creating a key and
    so may reject the proposed key between preparse and allocation.

    (3) A default manager function is provided that permits keys to be
    restricted to only asymmetric keys that are vouched for by the
    contents of the system keyring.

    A second manager function is provided that just rejects with EPERM.

    (4) A key allocation flag, KEY_ALLOC_BYPASS_RESTRICTION, is made available
    so that the kernel can initialise keyrings with keys that form the
    root of the trust relationship.

    (5) KEY_FLAG_TRUSTED and KEY_FLAG_TRUSTED_ONLY are removed, along with
    key_preparsed_payload::trusted.

    This change also makes it possible in future for userspace to create a private
    set of trusted keys and then to have it sealed by setting a manager function
    where the private set is wholly independent of the kernel's trust
    relationships.

    Further changes in the set involve extracting certain IMA special keyrings
    and making them generally global:

    (*) .system_keyring is renamed to .builtin_trusted_keys and remains read
    only. It carries only keys built in to the kernel. It may be where
    UEFI keys should be loaded - though that could better be the new
    secondary keyring (see below) or a separate UEFI keyring.

    (*) An optional secondary system keyring (called .secondary_trusted_keys)
    is added to replace the IMA MOK keyring.

    (*) Keys can be added to the secondary keyring by root if the keys can
    be vouched for by either ring of system keys.

    (*) Module signing and kexec only use .builtin_trusted_keys and do not use
    the new secondary keyring.

    (*) Config option SYSTEM_TRUSTED_KEYS now depends on ASYMMETRIC_KEY_TYPE as
    that's the only type currently permitted on the system keyrings.

    (*) A new config option, IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY,
    is provided to allow keys to be added to IMA keyrings, subject to the
    restriction that such keys are validly signed by a key already in the
    system keyrings.

    If this option is enabled, but secondary keyrings aren't, additions to
    the IMA keyrings will be restricted to signatures verifiable by keys in
    the builtin system keyring only.

    Signed-off-by: David Howells

    David Howells
     

04 May, 2016

1 commit


01 May, 2016

2 commits

  • Commit 3034a14 "ima: pass 'opened' flag to identify newly created files"
    stopped identifying empty files as new files. However new empty files
    can be created using the mknodat syscall. On systems with IMA-appraisal
    enabled, these empty files are not labeled with security.ima extended
    attributes properly, preventing them from subsequently being opened in
    order to write the file data contents. This patch defines a new hook
    named ima_post_path_mknod() to mark these empty files, created using
    mknodat, as new in order to allow the file data contents to be written.

    In addition, files with security.ima xattrs containing a file signature
    are considered "immutable" and can not be modified. The file contents
    need to be written, before signing the file. This patch relaxes this
    requirement for new files, allowing the file signature to be written
    before the file contents.

    Changelog:
    - defer identifying files with signatures stored as security.ima
    (based on Dmitry Rozhkov's comments)
    - removing tests (eg. dentry, dentry->d_inode, inode->i_size == 0)
    (based on Al's review)

    Signed-off-by: Mimi Zohar
    Cc: Al Viro <
    Tested-by: Dmitry Rozhkov

    Mimi Zohar
     
  • Changing file metadata (eg. uid, guid) could result in having to
    re-appraise a file's integrity, but does not change the "new file"
    status nor the security.ima xattr. The IMA_PERMIT_DIRECTIO and
    IMA_DIGSIG_REQUIRED flags are policy rule specific. This patch
    only resets these flags, not the IMA_NEW_FILE or IMA_DIGSIG flags.

    With this patch, changing the file timestamp will not remove the
    file signature on new files.

    Reported-by: Dmitry Rozhkov
    Signed-off-by: Mimi Zohar
    Tested-by: Dmitry Rozhkov

    Mimi Zohar
     

27 Apr, 2016

2 commits

  • The execstack check was only being applied on the main
    process stack. Thread stacks allocated via mmap were
    only subject to the execmem permission check. Augment
    the check to apply to the current thread stack as well.
    Note that this does NOT prevent making a different thread's
    stack executable.

    Suggested-by: Nick Kralevich
    Acked-by: Nick Kralevich
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • Distinguish capability checks against a target associated
    with the init user namespace versus capability checks against
    a target associated with a non-init user namespace by defining
    and using separate security classes for the latter.

    This is needed to support e.g. Chrome usage of user namespaces
    for the Chrome sandbox without needing to allow Chrome to also
    exercise capabilities on targets in the init user namespace.

    Suggested-by: Dan Walsh
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

23 Apr, 2016

1 commit

  • security_settime() uses a timespec, which is not year 2038 safe
    on 32bit systems. Thus this patch introduces the security_settime64()
    function with timespec64 type. We also convert the cap_settime() helper
    function to use the 64bit types.

    This patch then moves security_settime() to the header file as an
    inline helper function so that existing users can be iteratively
    converted.

    None of the existing hooks is using the timespec argument and therefor
    the patch is not making any functional changes.

    Cc: Serge Hallyn ,
    Cc: James Morris ,
    Cc: "Serge E. Hallyn" ,
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Kees Cook
    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Reviewed-by: James Morris
    Signed-off-by: Baolin Wang
    [jstultz: Reworded commit message]
    Signed-off-by: John Stultz

    Baolin Wang
     

21 Apr, 2016

3 commits

  • This LSM enforces that kernel-loaded files (modules, firmware, etc)
    must all come from the same filesystem, with the expectation that
    such a filesystem is backed by a read-only device such as dm-verity
    or CDROM. This allows systems that have a verified and/or unchangeable
    filesystem to enforce module and firmware loading restrictions without
    needing to sign the files individually.

    Signed-off-by: Kees Cook
    Acked-by: Serge Hallyn
    Signed-off-by: James Morris

    Kees Cook
     
  • Use a common error reporting function for Yama violation reports, and give
    more detail into the process command lines.

    Signed-off-by: Kees Cook
    Signed-off-by: James Morris

    Kees Cook
     
  • This patch adds a new RTM_GETSTATS message to query link stats via netlink
    from the kernel. RTM_NEWLINK also dumps stats today, but RTM_NEWLINK
    returns a lot more than just stats and is expensive in some cases when
    frequent polling for stats from userspace is a common operation.

    RTM_GETSTATS is an attempt to provide a light weight netlink message
    to explicity query only link stats from the kernel on an interface.
    The idea is to also keep it extensible so that new kinds of stats can be
    added to it in the future.

    This patch adds the following attribute for NETDEV stats:
    struct nla_policy ifla_stats_policy[IFLA_STATS_MAX + 1] = {
    [IFLA_STATS_LINK_64] = { .len = sizeof(struct rtnl_link_stats64) },
    };

    Like any other rtnetlink message, RTM_GETSTATS can be used to get stats of
    a single interface or all interfaces with NLM_F_DUMP.

    Future possible new types of stat attributes:
    link af stats:
    - IFLA_STATS_LINK_IPV6 (nested. for ipv6 stats)
    - IFLA_STATS_LINK_MPLS (nested. for mpls/mdev stats)
    extended stats:
    - IFLA_STATS_LINK_EXTENDED (nested. extended software netdev stats like bridge,
    vlan, vxlan etc)
    - IFLA_STATS_LINK_HW_EXTENDED (nested. extended hardware stats which are
    available via ethtool today)

    This patch also declares a filter mask for all stat attributes.
    User has to provide a mask of stats attributes to query. filter mask
    can be specified in the new hdr 'struct if_stats_msg' for stats messages.
    Other important field in the header is the ifindex.

    This api can also include attributes for global stats (eg tcp) in the future.
    When global stats are included in a stats msg, the ifindex in the header
    must be zero. A single stats message cannot contain both global and
    netdev specific stats. To easily distinguish them, netdev specific stat
    attributes name are prefixed with IFLA_STATS_LINK_

    Without any attributes in the filter_mask, no stats will be returned.

    This patch has been tested with mofified iproute2 ifstat.

    Suggested-by: Jamal Hadi Salim
    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Roopa Prabhu
     

20 Apr, 2016

3 commits


14 Apr, 2016

1 commit

  • security_get_bool_value(int bool) argument "bool" conflicts with
    in-kernel macros such as BUILD_BUG(). This patch changes this to
    index which isn't a type.

    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Eric Paris
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: Rasmus Villemoes
    Cc: Andrew Perepechko
    Cc: Jeff Vander Stoep
    Cc: selinux@tycho.nsa.gov
    Cc: Eric Paris
    Cc: Paul Moore
    Cc: David Howells
    Signed-off-by: Prarit Bhargava
    Acked-by: David Howells
    [PM: wrapped description for checkpatch.pl, use "selinux:..." as subj]
    Signed-off-by: Paul Moore

    Prarit Bhargava
     

13 Apr, 2016

4 commits

  • This adds userspace access to Diffie-Hellman computations through a
    new keyctl() syscall command to calculate shared secrets or public
    keys using input parameters stored in the keyring.

    Input key ids are provided in a struct due to the current 5-arg limit
    for the keyctl syscall. Only user keys are supported in order to avoid
    exposing the content of logon or encrypted keys.

    The output is written to the provided buffer, based on the assumption
    that the values are only needed in userspace.

    Future support for other types of key derivation would involve a new
    command, like KEYCTL_ECDH_COMPUTE.

    Once Diffie-Hellman support is included in the crypto API, this code
    can be converted to use the crypto API to take advantage of possible
    hardware acceleration and reduce redundant code.

    Signed-off-by: Mat Martineau
    Signed-off-by: David Howells

    Mat Martineau
     
  • Solved TODO task: big keys saved to shmem file are now stored encrypted.
    The encryption key is randomly generated and saved to payload[big_key_data].

    Signed-off-by: Kirill Marinushkin
    Signed-off-by: David Howells

    Kirill Marinushkin
     
  • The payload preparsing routine for user keys makes a copy of the payload
    provided by the caller and stashes it in the key_preparsed_payload struct for
    ->instantiate() or ->update() to use. However, ->update() takes another copy
    of this to attach to the keyring. ->update() should be using this directly
    and clearing the pointer in the preparse data.

    Signed-off-by: David Howells

    David Howells
     
  • Commit d43de6c780a8 ("akcipher: Move the RSA DER encoding check to
    the crypto layer") removed the Kconfig option PUBLIC_KEY_ALGO_RSA,
    but forgot to remove a 'select' to this option in the definition of
    INTEGRITY_ASYMMETRIC_KEYS.

    Let's remove the select, as it's ineffective now.

    Signed-off-by: Andreas Ziegler
    Signed-off-by: David Howells

    Andreas Ziegler
     

12 Apr, 2016

2 commits

  • Add a config option (IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
    that, when enabled, allows keys to be added to the IMA keyrings by
    userspace - with the restriction that each must be signed by a key in the
    system trusted keyrings.

    EPERM will be returned if this option is disabled, ENOKEY will be returned if
    no authoritative key can be found and EKEYREJECTED will be returned if the
    signature doesn't match. Other errors such as ENOPKG may also be returned.

    If this new option is enabled, the builtin system keyring is searched, as is
    the secondary system keyring if that is also enabled. Intermediate keys
    between the builtin system keyring and the key being added can be added to
    the secondary keyring (which replaces .ima_mok) to form a trust chain -
    provided they are also validly signed by a key in one of the trusted keyrings.

    The .ima_mok keyring is then removed and the IMA blacklist keyring gets its
    own config option (IMA_BLACKLIST_KEYRING).

    Signed-off-by: David Howells
    Signed-off-by: Mimi Zohar

    David Howells
     
  • Remove KEY_FLAG_TRUSTED and KEY_ALLOC_TRUSTED as they're no longer
    meaningful. Also we can drop the trusted flag from the preparse structure.

    Given this, we no longer need to pass the key flags through to
    restrict_link().

    Further, we can now get rid of keyring_restrict_trusted_only() also.

    Signed-off-by: David Howells

    David Howells