09 Jan, 2020

1 commit

  • commit 8c62ed27a12c00e3db1c9f04bc0f272bdbb06734 upstream.

    aa_xattrs_match() is unfortunately calling vfs_getxattr_alloc() from a
    context protected by an rcu_read_lock. This can not be done as
    vfs_getxattr_alloc() may sleep regardles of the gfp_t value being
    passed to it.

    Fix this by breaking the rcu_read_lock on the policy search when the
    xattr match feature is requested and restarting the search if a policy
    changes occur.

    Fixes: 8e51f9087f40 ("apparmor: Add support for attaching profiles via xattr, presence and value")
    Reported-by: Jia-Ju Bai
    Reported-by: Al Viro
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

05 Jan, 2020

1 commit

  • [ Upstream commit 00e0590dbaec6f1bcaa36a85467d7e3497ced522 ]

    The sanity check in macro update_for_len checks to see if len
    is less than zero, however, len is a size_t so it can never be
    less than zero, so this sanity check is a no-op. Fix this by
    making len a ssize_t so the comparison will work and add ulen
    that is a size_t copy of len so that the min() macro won't
    throw warnings about comparing different types.

    Addresses-Coverity: ("Macro compares unsigned to 0")
    Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels")
    Signed-off-by: Colin Ian King
    Signed-off-by: John Johansen
    Signed-off-by: Sasha Levin

    Colin Ian King
     

20 Jul, 2019

1 commit

  • Pull vfs mount updates from Al Viro:
    "The first part of mount updates.

    Convert filesystems to use the new mount API"

    * 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits)
    mnt_init(): call shmem_init() unconditionally
    constify ksys_mount() string arguments
    don't bother with registering rootfs
    init_rootfs(): don't bother with init_ramfs_fs()
    vfs: Convert smackfs to use the new mount API
    vfs: Convert selinuxfs to use the new mount API
    vfs: Convert securityfs to use the new mount API
    vfs: Convert apparmorfs to use the new mount API
    vfs: Convert openpromfs to use the new mount API
    vfs: Convert xenfs to use the new mount API
    vfs: Convert gadgetfs to use the new mount API
    vfs: Convert oprofilefs to use the new mount API
    vfs: Convert ibmasmfs to use the new mount API
    vfs: Convert qib_fs/ipathfs to use the new mount API
    vfs: Convert efivarfs to use the new mount API
    vfs: Convert configfs to use the new mount API
    vfs: Convert binfmt_misc to use the new mount API
    convenience helper: get_tree_single()
    convenience helper get_tree_nodev()
    vfs: Kill sget_userns()
    ...

    Linus Torvalds
     

09 Jul, 2019

1 commit

  • Pull locking updates from Ingo Molnar:
    "The main changes in this cycle are:

    - rwsem scalability improvements, phase #2, by Waiman Long, which are
    rather impressive:

    "On a 2-socket 40-core 80-thread Skylake system with 40 reader
    and writer locking threads, the min/mean/max locking operations
    done in a 5-second testing window before the patchset were:

    40 readers, Iterations Min/Mean/Max = 1,807/1,808/1,810
    40 writers, Iterations Min/Mean/Max = 1,807/50,344/151,255

    After the patchset, they became:

    40 readers, Iterations Min/Mean/Max = 30,057/31,359/32,741
    40 writers, Iterations Min/Mean/Max = 94,466/95,845/97,098"

    There's a lot of changes to the locking implementation that makes
    it similar to qrwlock, including owner handoff for more fair
    locking.

    Another microbenchmark shows how across the spectrum the
    improvements are:

    "With a locking microbenchmark running on 5.1 based kernel, the
    total locking rates (in kops/s) on a 2-socket Skylake system
    with equal numbers of readers and writers (mixed) before and
    after this patchset were:

    # of Threads Before Patch After Patch
    ------------ ------------ -----------
    2 2,618 4,193
    4 1,202 3,726
    8 802 3,622
    16 729 3,359
    32 319 2,826
    64 102 2,744"

    The changes are extensive and the patch-set has been through
    several iterations addressing various locking workloads. There
    might be more regressions, but unless they are pathological I
    believe we want to use this new implementation as the baseline
    going forward.

    - jump-label optimizations by Daniel Bristot de Oliveira: the primary
    motivation was to remove IPI disturbance of isolated RT-workload
    CPUs, which resulted in the implementation of batched jump-label
    updates. Beyond the improvement of the real-time characteristics
    kernel, in one test this patchset improved static key update
    overhead from 57 msecs to just 1.4 msecs - which is a nice speedup
    as well.

    - atomic64_t cross-arch type cleanups by Mark Rutland: over the last
    ~10 years of atomic64_t existence the various types used by the
    APIs only had to be self-consistent within each architecture -
    which means they became wildly inconsistent across architectures.
    Mark puts and end to this by reworking all the atomic64
    implementations to use 's64' as the base type for atomic64_t, and
    to ensure that this type is consistently used for parameters and
    return values in the API, avoiding further problems in this area.

    - A large set of small improvements to lockdep by Yuyang Du: type
    cleanups, output cleanups, function return type and othr cleanups
    all around the place.

    - A set of percpu ops cleanups and fixes by Peter Zijlstra.

    - Misc other changes - please see the Git log for more details"

    * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (82 commits)
    locking/lockdep: increase size of counters for lockdep statistics
    locking/atomics: Use sed(1) instead of non-standard head(1) option
    locking/lockdep: Move mark_lock() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING
    x86/jump_label: Make tp_vec_nr static
    x86/percpu: Optimize raw_cpu_xchg()
    x86/percpu, sched/fair: Avoid local_clock()
    x86/percpu, x86/irq: Relax {set,get}_irq_regs()
    x86/percpu: Relax smp_processor_id()
    x86/percpu: Differentiate this_cpu_{}() and __this_cpu_{}()
    locking/rwsem: Guard against making count negative
    locking/rwsem: Adaptive disabling of reader optimistic spinning
    locking/rwsem: Enable time-based spinning on reader-owned rwsem
    locking/rwsem: Make rwsem->owner an atomic_long_t
    locking/rwsem: Enable readers spinning on writer
    locking/rwsem: Clarify usage of owner's nonspinaable bit
    locking/rwsem: Wake up almost all readers in wait queue
    locking/rwsem: More optimal RT task handling of null owner
    locking/rwsem: Always release wait_lock before waking up tasks
    locking/rwsem: Implement lock handoff to prevent lock starvation
    locking/rwsem: Make rwsem_spin_on_owner() return owner state
    ...

    Linus Torvalds
     

05 Jul, 2019

1 commit

  • Convert the apparmorfs filesystem to the new internal mount API as the old
    one will be obsoleted and removed. This allows greater flexibility in
    communication of mount parameters between userspace, the VFS and the
    filesystem.

    See Documentation/filesystems/mount_api.txt for more information.

    Signed-off-by: David Howells
    cc: John Johansen
    cc: apparmor@lists.ubuntu.com
    cc: linux-security-module@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     

19 Jun, 2019

3 commits

  • Each function that manipulates the aa_ext struct should reset it's "pos"
    member on failure. This ensures that, on failure, no changes are made to
    the state of the aa_ext struct.

    There are paths were elements are optional and the error path is
    used to indicate the optional element is not present. This means
    instead of just aborting on error the unpack stream can become
    unsynchronized on optional elements, if using one of the affected
    functions.

    Cc: stable@vger.kernel.org
    Fixes: 736ec752d95e ("AppArmor: policy routines for loading and unpacking policy")
    Signed-off-by: Mike Salvatore
    Signed-off-by: John Johansen

    Mike Salvatore
     
  • A packed AppArmor policy contains null-terminated tag strings that are read
    by unpack_nameX(). However, unpack_nameX() uses string functions on them
    without ensuring that they are actually null-terminated, potentially
    leading to out-of-bounds accesses.

    Make sure that the tag string is null-terminated before passing it to
    strcmp().

    Cc: stable@vger.kernel.org
    Fixes: 736ec752d95e ("AppArmor: policy routines for loading and unpacking policy")
    Signed-off-by: Jann Horn
    Signed-off-by: John Johansen

    Jann Horn
     
  • While commit 11c236b89d7c2 ("apparmor: add a default null dfa") ensure
    every profile has a policy.dfa it does not resize the policy.start[]
    to have entries for every possible start value. Which means
    PROFILE_MEDIATES is not safe to use on untrusted input. Unforunately
    commit b9590ad4c4f2 ("apparmor: remove POLICY_MEDIATES_SAFE") did not
    take into account the start value usage.

    The input string in profile_query_cb() is user controlled and is not
    properly checked to be within the limited start[] entries, even worse
    it can't be as userspace policy is allowed to make us of entries types
    the kernel does not know about. This mean usespace can currently cause
    the kernel to access memory up to 240 entries beyond the start array
    bounds.

    Cc: stable@vger.kernel.org
    Fixes: b9590ad4c4f2 ("apparmor: remove POLICY_MEDIATES_SAFE")
    Signed-off-by: John Johansen

    John Johansen
     

17 Jun, 2019

1 commit

  • All callers of lockdep_assert_held_exclusive() use it to verify the
    correct locking state of either a semaphore (ldisc_sem in tty,
    mmap_sem for perf events, i_rwsem of inode for dax) or rwlock by
    apparmor. Thus it makes sense to rename _exclusive to _write since
    that's the semantics callers care. Additionally there is already
    lockdep_assert_held_read(), which this new naming is more consistent with.

    No functional changes.

    Signed-off-by: Nikolay Borisov
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: https://lkml.kernel.org/r/20190531100651.3969-1-nborisov@suse.com
    Signed-off-by: Ingo Molnar

    Nikolay Borisov
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation version 2 of the license

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 315 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Armijn Hemel
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531190115.503150771@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


08 May, 2019

1 commit

  • Pull vfs inode freeing updates from Al Viro:
    "Introduction of separate method for RCU-delayed part of
    ->destroy_inode() (if any).

    Pretty much as posted, except that destroy_inode() stashes
    ->free_inode into the victim (anon-unioned with ->i_fops) before
    scheduling i_callback() and the last two patches (sockfs conversion
    and folding struct socket_wq into struct socket) are excluded - that
    pair should go through netdev once davem reopens his tree"

    * 'work.icache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (58 commits)
    orangefs: make use of ->free_inode()
    shmem: make use of ->free_inode()
    hugetlb: make use of ->free_inode()
    overlayfs: make use of ->free_inode()
    jfs: switch to ->free_inode()
    fuse: switch to ->free_inode()
    ext4: make use of ->free_inode()
    ecryptfs: make use of ->free_inode()
    ceph: use ->free_inode()
    btrfs: use ->free_inode()
    afs: switch to use of ->free_inode()
    dax: make use of ->free_inode()
    ntfs: switch to ->free_inode()
    securityfs: switch to ->free_inode()
    apparmor: switch to ->free_inode()
    rpcpipe: switch to ->free_inode()
    bpf: switch to ->free_inode()
    mqueue: switch to ->free_inode()
    ufs: switch to ->free_inode()
    coda: switch to ->free_inode()
    ...

    Linus Torvalds
     

07 May, 2019

1 commit

  • Pull crypto update from Herbert Xu:
    "API:
    - Add support for AEAD in simd
    - Add fuzz testing to testmgr
    - Add panic_on_fail module parameter to testmgr
    - Use per-CPU struct instead multiple variables in scompress
    - Change verify API for akcipher

    Algorithms:
    - Convert x86 AEAD algorithms over to simd
    - Forbid 2-key 3DES in FIPS mode
    - Add EC-RDSA (GOST 34.10) algorithm

    Drivers:
    - Set output IV with ctr-aes in crypto4xx
    - Set output IV in rockchip
    - Fix potential length overflow with hashing in sun4i-ss
    - Fix computation error with ctr in vmx
    - Add SM4 protected keys support in ccree
    - Remove long-broken mxc-scc driver
    - Add rfc4106(gcm(aes)) cipher support in cavium/nitrox"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (179 commits)
    crypto: ccree - use a proper le32 type for le32 val
    crypto: ccree - remove set but not used variable 'du_size'
    crypto: ccree - Make cc_sec_disable static
    crypto: ccree - fix spelling mistake "protedcted" -> "protected"
    crypto: caam/qi2 - generate hash keys in-place
    crypto: caam/qi2 - fix DMA mapping of stack memory
    crypto: caam/qi2 - fix zero-length buffer DMA mapping
    crypto: stm32/cryp - update to return iv_out
    crypto: stm32/cryp - remove request mutex protection
    crypto: stm32/cryp - add weak key check for DES
    crypto: atmel - remove set but not used variable 'alg_name'
    crypto: picoxcell - Use dev_get_drvdata()
    crypto: crypto4xx - get rid of redundant using_sd variable
    crypto: crypto4xx - use sync skcipher for fallback
    crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues
    crypto: crypto4xx - fix ctr-aes missing output IV
    crypto: ecrdsa - select ASN1 and OID_REGISTRY for EC-RDSA
    crypto: ux500 - use ccflags-y instead of CFLAGS_.o
    crypto: ccree - handle tee fips error during power management resume
    crypto: ccree - add function to handle cryptocell tee fips error
    ...

    Linus Torvalds
     

06 May, 2019

1 commit

  • Pull vfs fixes from Al Viro:

    - a couple of ->i_link use-after-free fixes

    - regression fix for wrong errno on absent device name in mount(2)
    (this cycle stuff)

    - ancient UFS braino in large GID handling on Solaris UFS images (bogus
    cut'n'paste from large UID handling; wrong field checked to decide
    whether we should look at old (16bit) or new (32bit) field)

    * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    ufs: fix braino in ufs_get_inode_gid() for solaris UFS flavour
    Abort file_remove_privs() for non-reg. files
    [fix] get rid of checking for absent device name in vfs_get_tree()
    apparmorfs: fix use-after-free on symlink traversal
    securityfs: fix use-after-free on symlink traversal

    Linus Torvalds
     

02 May, 2019

1 commit


25 Apr, 2019

1 commit

  • The flags field in 'struct shash_desc' never actually does anything.
    The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
    However, no shash algorithm ever sleeps, making this flag a no-op.

    With this being the case, inevitably some users who can't sleep wrongly
    pass MAY_SLEEP. These would all need to be fixed if any shash algorithm
    actually started sleeping. For example, the shash_ahash_*() functions,
    which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
    from the ahash API to the shash API. However, the shash functions are
    called under kmap_atomic(), so actually they're assumed to never sleep.

    Even if it turns out that some users do need preemption points while
    hashing large buffers, we could easily provide a helper function
    crypto_shash_update_large() which divides the data into smaller chunks
    and calls crypto_shash_update() and cond_resched() for each chunk. It's
    not necessary to have a flag in 'struct shash_desc', nor is it necessary
    to make individual shash algorithms aware of this at all.

    Therefore, remove shash_desc::flags, and document that the
    crypto_shash_*() functions can be called from any context.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

11 Apr, 2019

1 commit


10 Apr, 2019

1 commit

  • Before commit c5459b829b71 ("LSM: Plumb visibility into optional "enabled"
    state"), /sys/module/apparmor/parameters/enabled would show "Y" or "N"
    since it was using the "bool" handler. After being changed to "int",
    this switched to "1" or "0", breaking the userspace AppArmor detection
    of dbus-broker. This restores the Y/N output while keeping the LSM
    infrastructure happy.

    Before:
    $ cat /sys/module/apparmor/parameters/enabled
    1

    After:
    $ cat /sys/module/apparmor/parameters/enabled
    Y

    Reported-by: David Rheinsberg
    Reviewed-by: David Rheinsberg
    Link: https://lkml.kernel.org/r/CADyDSO6k8vYb1eryT4g6+EHrLCvb68GAbHVWuULkYjcZcYNhhw@mail.gmail.com
    Fixes: c5459b829b71 ("LSM: Plumb visibility into optional "enabled" state")
    Signed-off-by: Kees Cook
    Signed-off-by: John Johansen

    Kees Cook
     

14 Mar, 2019

1 commit

  • …git/jj/linux-apparmor

    Pull apparmor fixes from John Johansen:

    - fix double when failing to unpack secmark rules in policy

    - fix leak of dentry when profile is removed

    * tag 'apparmor-pr-2019-03-12' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor:
    apparmor: fix double free when unpack of secmark rules fails
    apparmor: delete the dentry in aafs_remove() to avoid a leak
    apparmor: Fix warning about unused function apparmor_ipv6_postroute

    Linus Torvalds
     

12 Mar, 2019

2 commits

  • if secmark rules fail to unpack a double free happens resulting in
    the following oops

    [ 1295.584074] audit: type=1400 audit(1549970525.256:51): apparmor="STATUS" info="failed to unpack profile secmark rules" error=-71 profile="unconfined" name="/root/test" pid=29882 comm="apparmor_parser" name="/root/test" offset=120
    [ 1374.042334] ------------[ cut here ]------------
    [ 1374.042336] kernel BUG at mm/slub.c:294!
    [ 1374.042404] invalid opcode: 0000 [#1] SMP PTI
    [ 1374.042436] CPU: 0 PID: 29921 Comm: apparmor_parser Not tainted 4.20.7-042007-generic #201902061234
    [ 1374.042461] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
    [ 1374.042489] RIP: 0010:kfree+0x164/0x180
    [ 1374.042502] Code: 74 05 41 0f b6 72 51 4c 89 d7 e8 37 cd f8 ff eb 8b 41 b8 01 00 00 00 48 89 d9 48 89 da 4c 89 d6 e8 11 f6 ff ff e9 72 ff ff ff 0b 49 8b 42 08 a8 01 75 c2 0f 0b 48 8b 3d a9 f4 19 01 e9 c5 fe
    [ 1374.042552] RSP: 0018:ffffaf7b812d7b90 EFLAGS: 00010246
    [ 1374.042568] RAX: ffff91e437679200 RBX: ffff91e437679200 RCX: ffff91e437679200
    [ 1374.042589] RDX: 00000000000088b6 RSI: ffff91e43da27060 RDI: ffff91e43d401a80
    [ 1374.042609] RBP: ffffaf7b812d7ba8 R08: 0000000000027080 R09: ffffffffa6627a6d
    [ 1374.042629] R10: ffffd3af41dd9e40 R11: ffff91e43a1740dc R12: ffff91e3f52e8000
    [ 1374.042650] R13: ffffffffa6627a6d R14: ffffffffffffffb9 R15: 0000000000000001
    [ 1374.042675] FS: 00007f928df77740(0000) GS:ffff91e43da00000(0000) knlGS:0000000000000000
    [ 1374.042697] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 1374.042714] CR2: 000055a0c3ab6b50 CR3: 0000000079ed8004 CR4: 0000000000360ef0
    [ 1374.042737] Call Trace:
    [ 1374.042750] kzfree+0x2d/0x40
    [ 1374.042763] aa_free_profile+0x12b/0x270
    [ 1374.042776] unpack_profile+0xc1/0xf10
    [ 1374.042790] aa_unpack+0x115/0x4e0
    [ 1374.042802] aa_replace_profiles+0x8e/0xcc0
    [ 1374.042817] ? kvmalloc_node+0x6d/0x80
    [ 1374.042831] ? __check_object_size+0x166/0x192
    [ 1374.042845] policy_update+0xcf/0x1b0
    [ 1374.042858] profile_load+0x7d/0xa0
    [ 1374.042871] __vfs_write+0x3a/0x190
    [ 1374.042883] ? apparmor_file_permission+0x1a/0x20
    [ 1374.042899] ? security_file_permission+0x31/0xc0
    [ 1374.042918] ? _cond_resched+0x19/0x30
    [ 1374.042931] vfs_write+0xab/0x1b0
    [ 1374.042963] ksys_write+0x55/0xc0
    [ 1374.043004] __x64_sys_write+0x1a/0x20
    [ 1374.043046] do_syscall_64+0x5a/0x110
    [ 1374.043087] entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Fixes: 9caafbe2b4cf ("apparmor: Parse secmark policy")
    Reported-by: Alex Murray
    Signed-off-by: John Johansen

    John Johansen
     
  • Although the apparmorfs dentries are always dropped from the dentry cache
    when the usage count drops to zero, there is no guarantee that this will
    happen in aafs_remove(), as another thread might still be using it. In
    this scenario, this means that the dentry will temporarily continue to
    appear in the results of lookups, even after the call to aafs_remove().

    In the case of removal of a profile - it also causes simple_rmdir()
    on the profile directory to fail, as the directory won't be empty until
    the usage counts of all child dentries have decreased to zero. This
    results in the dentry for the profile directory leaking and appearing
    empty in the file system tree forever.

    Signed-off-by: Chris Coulson
    Signed-off-by: John Johansen

    Chris Coulson
     

08 Mar, 2019

2 commits

  • Pull audit updates from Paul Moore:
    "A lucky 13 audit patches for v5.1.

    Despite the rather large diffstat, most of the changes are from two
    bug fix patches that move code from one Kconfig option to another.

    Beyond that bit of churn, the remaining changes are largely cleanups
    and bug-fixes as we slowly march towards container auditing. It isn't
    all boring though, we do have a couple of new things: file
    capabilities v3 support, and expanded support for filtering on
    filesystems to solve problems with remote filesystems.

    All changes pass the audit-testsuite. Please merge for v5.1"

    * tag 'audit-pr-20190305' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: mark expected switch fall-through
    audit: hide auditsc_get_stamp and audit_serial prototypes
    audit: join tty records to their syscall
    audit: remove audit_context when CONFIG_ AUDIT and not AUDITSYSCALL
    audit: remove unused actx param from audit_rule_match
    audit: ignore fcaps on umount
    audit: clean up AUDITSYSCALL prototypes and stubs
    audit: more filter PATH records keyed on filesystem magic
    audit: add support for fcaps v3
    audit: move loginuid and sessionid from CONFIG_AUDITSYSCALL to CONFIG_AUDIT
    audit: add syscall information to CONFIG_CHANGE records
    audit: hand taken context to audit_kill_trees for syscall logging
    audit: give a clue what CONFIG_CHANGE op was involved

    Linus Torvalds
     
  • Pull security subsystem updates from James Morris:

    - Extend LSM stacking to allow sharing of cred, file, ipc, inode, and
    task blobs. This paves the way for more full-featured LSMs to be
    merged, and is specifically aimed at LandLock and SARA LSMs. This
    work is from Casey and Kees.

    - There's a new LSM from Micah Morton: "SafeSetID gates the setid
    family of syscalls to restrict UID/GID transitions from a given
    UID/GID to only those approved by a system-wide whitelist." This
    feature is currently shipping in ChromeOS.

    * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (62 commits)
    keys: fix missing __user in KEYCTL_PKEY_QUERY
    LSM: Update list of SECURITYFS users in Kconfig
    LSM: Ignore "security=" when "lsm=" is specified
    LSM: Update function documentation for cap_capable
    security: mark expected switch fall-throughs and add a missing break
    tomoyo: Bump version.
    LSM: fix return value check in safesetid_init_securityfs()
    LSM: SafeSetID: add selftest
    LSM: SafeSetID: remove unused include
    LSM: SafeSetID: 'depend' on CONFIG_SECURITY
    LSM: Add 'name' field for SafeSetID in DEFINE_LSM
    LSM: add SafeSetID module that gates setid calls
    LSM: add SafeSetID module that gates setid calls
    tomoyo: Allow multiple use_group lines.
    tomoyo: Coding style fix.
    tomoyo: Swicth from cred->security to task_struct->security.
    security: keys: annotate implicit fall throughs
    security: keys: annotate implicit fall throughs
    security: keys: annotate implicit fall through
    capabilities:: annotate implicit fall through
    ...

    Linus Torvalds
     

23 Feb, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch
    cases where we are expecting to fall through.

    This patch fixes the following warnings:

    security/integrity/ima/ima_template_lib.c:85:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
    security/integrity/ima/ima_policy.c:940:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
    security/integrity/ima/ima_policy.c:943:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    security/integrity/ima/ima_policy.c:972:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
    security/integrity/ima/ima_policy.c:974:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    security/smack/smack_lsm.c:3391:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
    security/apparmor/domain.c:569:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Warning level 3 was used: -Wimplicit-fallthrough=3

    Also, add a missing break statement to fix the following warning:

    security/integrity/ima/ima_appraise.c:116:26: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Acked-by: John Johansen
    Acked-by: Casey Schaufler
    Signed-off-by: Gustavo A. R. Silva
    Acked-by: Mimi Zohar
    Signed-off-by: James Morris

    Gustavo A. R. Silva
     

02 Feb, 2019

1 commit


01 Feb, 2019

2 commits

  • when compiled without CONFIG_IPV6:
    security/apparmor/lsm.c:1601:21: warning: ‘apparmor_ipv6_postroute’ defined but not used [-Wunused-function]
    static unsigned int apparmor_ipv6_postroute(void *priv,
    ^~~~~~~~~~~~~~~~~~~~~~~

    Reported-by: Jordan Glover
    Tested-by: Jordan Glover
    Signed-off-by: Petr Vorel
    Signed-off-by: John Johansen

    Petr Vorel
     
  • The audit_rule_match() struct audit_context *actx parameter is not used
    by any in-tree consumers (selinux, apparmour, integrity, smack).

    The audit context is an internal audit structure that should only be
    accessed by audit accessor functions.

    It was part of commit 03d37d25e0f9 ("LSM/Audit: Introduce generic
    Audit LSM hooks") but appears to have never been used.

    Remove it.

    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/107

    Signed-off-by: Richard Guy Briggs
    [PM: fixed the referenced commit title]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

23 Jan, 2019

1 commit


19 Jan, 2019

1 commit

  • Since current->cred == current->real_cred when ordered_lsm_init()
    is called, and lsm_early_cred()/lsm_early_task() need to be called
    between the amount of required bytes is determined and module specific
    initialization function is called, we can move these calls from
    individual modules to ordered_lsm_init().

    Signed-off-by: Tetsuo Handa
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Tetsuo Handa
     

11 Jan, 2019

1 commit

  • This patch provides a general mechanism for passing flags to the
    security_capable LSM hook. It replaces the specific 'audit' flag that is
    used to tell security_capable whether it should log an audit message for
    the given capability check. The reason for generalizing this flag
    passing is so we can add an additional flag that signifies whether
    security_capable is being called by a setid syscall (which is needed by
    the proposed SafeSetID LSM).

    Signed-off-by: Micah Morton
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    Micah Morton
     

09 Jan, 2019

9 commits

  • Move management of the task_struct->security blob out
    of the individual security modules and into the security
    infrastructure. Instead of allocating the blobs from within
    the modules the modules tell the infrastructure how much
    space is required, and the space is allocated there.
    The only user of this blob is AppArmor. The AppArmor use
    is abstracted to avoid future conflict.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Move management of the file->f_security blob out of the
    individual security modules and into the infrastructure.
    The modules no longer allocate or free the data, instead
    they tell the infrastructure how much space they require.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Move management of the cred security blob out of the
    security modules and into the security infrastructre.
    Instead of allocating and freeing space the security
    modules tell the infrastructure how much space they
    require.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Don't use the cred->security pointer directly.
    Provide a helper function that provides the security blob pointer.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • In preparation for removing CONFIG_DEFAULT_SECURITY, this removes the
    soon-to-be redundant SECURITY_APPARMOR_BOOTPARAM_VALUE. Since explicit
    ordering via CONFIG_LSM or "lsm=" will define whether an LSM is enabled or
    not, this CONFIG will become effectively ignored, so remove it. However,
    in order to stay backward-compatible with "security=apparmor", the enable
    variable defaults to true.

    Signed-off-by: Kees Cook

    Kees Cook
     
  • In order to both support old "security=" Legacy Major LSM selection, and
    handling real exclusivity, this creates LSM_FLAG_EXCLUSIVE and updates
    the selection logic to handle them.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • As a prerequisite to adjusting LSM selection logic in the future, this
    moves the selection logic up out of the individual major LSMs, making
    their init functions only run when actually enabled. This considers all
    LSMs enabled by default unless they specified an external "enable"
    variable.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler
    Reviewed-by: John Johansen

    Kees Cook
     
  • In preparation for lifting the "is this LSM enabled?" logic out of the
    individual LSMs, pass in any special enabled state tracking (as needed
    for SELinux, AppArmor, and LoadPin). This should be an "int" to include
    handling any future cases where "enabled" is exposed via sysctl which
    has no "bool" type.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler
    Reviewed-by: John Johansen

    Kees Cook
     
  • This adds a flag for the current "major" LSMs to distinguish them when
    we have a universal method for ordering all LSMs. It's called "legacy"
    since the distinction of "major" will go away in the blob-sharing world.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler
    Reviewed-by: John Johansen

    Kees Cook
     

06 Jan, 2019

1 commit

  • Pull vfs mount API prep from Al Viro:
    "Mount API prereqs.

    Mostly that's LSM mount options cleanups. There are several minor
    fixes in there, but nothing earth-shattering (leaks on failure exits,
    mostly)"

    * 'mount.part1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (27 commits)
    mount_fs: suppress MAC on MS_SUBMOUNT as well as MS_KERNMOUNT
    smack: rewrite smack_sb_eat_lsm_opts()
    smack: get rid of match_token()
    smack: take the guts of smack_parse_opts_str() into a new helper
    LSM: new method: ->sb_add_mnt_opt()
    selinux: rewrite selinux_sb_eat_lsm_opts()
    selinux: regularize Opt_... names a bit
    selinux: switch away from match_token()
    selinux: new helper - selinux_add_opt()
    LSM: bury struct security_mnt_opts
    smack: switch to private smack_mnt_opts
    selinux: switch to private struct selinux_mnt_opts
    LSM: hide struct security_mnt_opts from any generic code
    selinux: kill selinux_sb_get_mnt_opts()
    LSM: turn sb_eat_lsm_opts() into a method
    nfs_remount(): don't leak, don't ignore LSM options quietly
    btrfs: sanitize security_mnt_opts use
    selinux; don't open-code a loop in sb_finish_set_opts()
    LSM: split ->sb_set_mnt_opts() out of ->sb_kern_mount()
    new helper: security_sb_eat_lsm_opts()
    ...

    Linus Torvalds