19 Mar, 2019

1 commit

  • The conversion to kvmalloc() forgot to account for the possibility that
    p->type_attr_map_array might be null in policydb_destroy().

    Fix this by destroying its contents only if it is not NULL.

    Also make sure ebitmap_init() is called on all entries before
    policydb_destroy() can be called. Right now this is a no-op, because
    both kvcalloc() and ebitmap_init() just zero out the whole struct, but
    let's rather not rely on a specific implementation.

    Reported-by: syzbot+a57b2aff60832666fc28@syzkaller.appspotmail.com
    Fixes: acdf52d97f82 ("selinux: convert to kvmalloc")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

14 Mar, 2019

2 commits

  • Pull selinux fixes from Paul Moore:
    "Two small fixes for SELinux in v5.1: one adds a buffer length check to
    the SELinux SCTP code, the other ensures that the SELinux labeling for
    a NFS mount is not disabled if the filesystem is mounted twice"

    * tag 'selinux-pr-20190312' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    security/selinux: fix SECURITY_LSM_NATIVE_LABELS on reused superblock
    selinux: add the missing walk_size + len check in selinux_sctp_bind_connect

    Linus Torvalds
     
  • …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
     

13 Mar, 2019

2 commits

  • Pull vfs mount infrastructure updates from Al Viro:
    "The rest of core infrastructure; no new syscalls in that pile, but the
    old parts are switched to new infrastructure. At that point
    conversions of individual filesystems can happen independently; some
    are done here (afs, cgroup, procfs, etc.), there's also a large series
    outside of that pile dealing with NFS (quite a bit of option-parsing
    stuff is getting used there - it's one of the most convoluted
    filesystems in terms of mount-related logics), but NFS bits are the
    next cycle fodder.

    It got seriously simplified since the last cycle; documentation is
    probably the weakest bit at the moment - I considered dropping the
    commit introducing Documentation/filesystems/mount_api.txt (cutting
    the size increase by quarter ;-), but decided that it would be better
    to fix it up after -rc1 instead.

    That pile allows to do followup work in independent branches, which
    should make life much easier for the next cycle. fs/super.c size
    increase is unpleasant; there's a followup series that allows to
    shrink it considerably, but I decided to leave that until the next
    cycle"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (41 commits)
    afs: Use fs_context to pass parameters over automount
    afs: Add fs_context support
    vfs: Add some logging to the core users of the fs_context log
    vfs: Implement logging through fs_context
    vfs: Provide documentation for new mount API
    vfs: Remove kern_mount_data()
    hugetlbfs: Convert to fs_context
    cpuset: Use fs_context
    kernfs, sysfs, cgroup, intel_rdt: Support fs_context
    cgroup: store a reference to cgroup_ns into cgroup_fs_context
    cgroup1_get_tree(): separate "get cgroup_root to use" into a separate helper
    cgroup_do_mount(): massage calling conventions
    cgroup: stash cgroup_root reference into cgroup_fs_context
    cgroup2: switch to option-by-option parsing
    cgroup1: switch to option-by-option parsing
    cgroup: take options parsing into ->parse_monolithic()
    cgroup: fold cgroup1_mount() into cgroup1_get_tree()
    cgroup: start switching to fs_context
    ipc: Convert mqueue fs to fs_context
    proc: Add fs_context support to procfs
    ...

    Linus Torvalds
     
  • The flex arrays were being used for constant sized arrays, so there's no
    benefit to using flex_arrays over something simpler.

    Link: http://lkml.kernel.org/r/20181217131929.11727-4-kent.overstreet@gmail.com
    Signed-off-by: Kent Overstreet
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Eric Paris
    Cc: Alexey Dobriyan
    Cc: Al Viro
    Cc: Dave Hansen
    Cc: Marcelo Ricardo Leitner
    Cc: Matthew Wilcox
    Cc: Neil Horman
    Cc: Pravin B Shelar
    Cc: Shaohua Li
    Cc: Vlad Yasevich
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kent Overstreet
     

12 Mar, 2019

4 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
     
  • In the case when we're reusing a superblock, selinux_sb_clone_mnt_opts()
    fails to set set_kern_flags, with the result that
    nfs_clone_sb_security() incorrectly clears NFS_CAP_SECURITY_LABEL.

    The result is that if you mount the same NFS filesystem twice, NFS
    security labels are turned off, even if they would work fine if you
    mounted the filesystem only once.

    ("fixes" may be not exactly the right tag, it may be more like
    "fixed-other-cases-but-missed-this-one".)

    Cc: Scott Mayhew
    Cc: stable@vger.kernel.org
    Fixes: 0b4d3452b8b4 "security/selinux: allow security_sb_clone_mnt_opts..."
    Signed-off-by: J. Bruce Fields
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    J. Bruce Fields
     
  • As does in __sctp_connect(), when checking addrs in a while loop, after
    get the addr len according to sa_family, it's necessary to do the check
    walk_size + af->sockaddr_len > addrs_size to make sure it won't access
    an out-of-bounds addr.

    The same thing is needed in selinux_sctp_bind_connect(), otherwise an
    out-of-bounds issue can be triggered:

    [14548.772313] BUG: KASAN: slab-out-of-bounds in selinux_sctp_bind_connect+0x1aa/0x1f0
    [14548.927083] Call Trace:
    [14548.938072] dump_stack+0x9a/0xe9
    [14548.953015] print_address_description+0x65/0x22e
    [14548.996524] kasan_report.cold.6+0x92/0x1a6
    [14549.015335] selinux_sctp_bind_connect+0x1aa/0x1f0
    [14549.036947] security_sctp_bind_connect+0x58/0x90
    [14549.058142] __sctp_setsockopt_connectx+0x5a/0x150 [sctp]
    [14549.081650] sctp_setsockopt.part.24+0x1322/0x3ce0 [sctp]

    Cc: stable@vger.kernel.org
    Fixes: d452930fd3b9 ("selinux: Add SCTP support")
    Reported-by: Chunyu Hu
    Signed-off-by: Xin Long
    Reviewed-by: Marcelo Ricardo Leitner
    Signed-off-by: Paul Moore

    Xin Long
     

11 Mar, 2019

2 commits

  • Pull tpm updates from James Morris:

    - Clean up the transmission flow

    Cleaned up the whole transmission flow. Locking of the chip is now
    done in the level of tpm_try_get_ops() and tpm_put_ops() instead
    taking the chip lock inside tpm_transmit(). The nested calls inside
    tpm_transmit(), used with the resource manager, have been refactored
    out.

    Should make easier to perform more complex transactions with the TPM
    without making the subsystem a bigger mess (e.g. encrypted channel
    patches by James Bottomley).

    - PPI 1.3 support

    TPM PPI 1.3 introduces an additional optional command parameter that
    may be needed for some commands. Display the parameter if the command
    requires such a parameter. Only command 23 (SetPCRBanks) needs one.

    The PPI request file will show output like this then:

    # echo "23 16" > request
    # cat request
    23 16

    # echo "5" > request
    # cat request
    5

    - Extend all PCR banks in IMA

    Instead of static PCR banks array, the array of available PCR banks
    is now allocated dynamically. The digests sizes are determined
    dynamically using a probe PCR read without relying crypto's static
    list of hash algorithms.

    This should finally make sealing of measurements in IMA safe and
    secure.

    - TPM 2.0 selftests

    Added a test suite to tools/testing/selftests/tpm2 previously outside
    of the kernel tree: https://github.com/jsakkine-intel/tpm2-scripts

    * 'next-tpm' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (37 commits)
    tpm/ppi: Enable submission of optional command parameter for PPI 1.3
    tpm/ppi: Possibly show command parameter if TPM PPI 1.3 is used
    tpm/ppi: Display up to 101 operations as define for version 1.3
    tpm/ppi: rename TPM_PPI_REVISION_ID to TPM_PPI_REVISION_ID_1
    tpm/ppi: pass function revision ID to tpm_eval_dsm()
    tpm: pass an array of tpm_extend_digest structures to tpm_pcr_extend()
    KEYS: trusted: explicitly use tpm_chip structure from tpm_default_chip()
    tpm: move tpm_chip definition to include/linux/tpm.h
    tpm: retrieve digest size of unknown algorithms with PCR read
    tpm: rename and export tpm2_digest and tpm2_algorithms
    tpm: dynamically allocate the allocated_banks array
    tpm: remove @flags from tpm_transmit()
    tpm: take TPM chip power gating out of tpm_transmit()
    tpm: introduce tpm_chip_start() and tpm_chip_stop()
    tpm: remove TPM_TRANSMIT_UNLOCKED flag
    tpm: use tpm_try_get_ops() in tpm-sysfs.c.
    tpm: remove @space from tpm_transmit()
    tpm: move TPM space code out of tpm_transmit()
    tpm: move tpm_validate_commmand() to tpm2-space.c
    tpm: clean up tpm_try_transmit() error handling flow
    ...

    Linus Torvalds
     
  • …morris/linux-security

    Pull integrity updates from James Morris:
    "Mimi Zohar says:

    'Linux 5.0 introduced the platform keyring to allow verifying the IMA
    kexec kernel image signature using the pre-boot keys. This pull
    request similarly makes keys on the platform keyring accessible for
    verifying the PE kernel image signature.

    Also included in this pull request is a new IMA hook that tags tmp
    files, in policy, indicating the file hash needs to be calculated.
    The remaining patches are cleanup'"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    evm: Use defined constant for UUID representation
    ima: define ima_post_create_tmpfile() hook and add missing call
    evm: remove set but not used variable 'xattr'
    encrypted-keys: fix Opt_err/Opt_error = -1
    kexec, KEYS: Make use of platform keyring for signature verify
    integrity, KEYS: add a reference to platform keyring

    Linus Torvalds
     

10 Mar, 2019

1 commit

  • Pull documentation updates from Jonathan Corbet:
    "A fairly routine cycle for docs - lots of typo fixes, some new
    documents, and more translations. There's also some LICENSES
    adjustments from Thomas"

    * tag 'docs-5.1' of git://git.lwn.net/linux: (74 commits)
    docs: Bring some order to filesystem documentation
    Documentation/locking/lockdep: Drop last two chars of sample states
    doc: rcu: Suspicious RCU usage is a warning
    docs: driver-api: iio: fix errors in documentation
    Documentation/process/howto: Update for 4.x -> 5.x versioning
    docs: Explicitly state that the 'Fixes:' tag shouldn't split lines
    doc: security: Add kern-doc for lsm_hooks.h
    doc: sctp: Merge and clean up rst files
    Docs: Correct /proc/stat path
    scripts/spdxcheck.py: fix C++ comment style detection
    doc: fix typos in license-rules.rst
    Documentation: fix admin-guide/README.rst minimum gcc version requirement
    doc: process: complete removal of info about -git patches
    doc: translations: sync translations 'remove info about -git patches'
    perf-security: wrap paragraphs on 72 columns
    perf-security: elaborate on perf_events/Perf privileged users
    perf-security: document collected perf_events/Perf data categories
    perf-security: document perf_events/Perf resource control
    sysfs.txt: add note on available attribute macros
    docs: kernel-doc: typo "if ... if" -> "if ... is"
    ...

    Linus Torvalds
     

08 Mar, 2019

3 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 SELinux updates from Paul Moore:
    "Nine SELinux patches for v5.1, all bug fixes.

    As far as I'm concerned, nothing really jumps out as risky or special
    to me, but each commit has a decent description so you can judge for
    yourself. As usual, everything passes the selinux-testsuite; please
    merge for v5.1"

    * tag 'selinux-pr-20190305' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: fix avc audit messages
    selinux: replace BUG_ONs with WARN_ONs in avc.c
    selinux: log invalid contexts in AVCs
    selinux: replace some BUG_ON()s with a WARN_ON()
    selinux: inline some AVC functions used only once
    selinux: do not override context on context mounts
    selinux: never allow relabeling on context mounts
    selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link
    selinux: avoid silent denials in permissive mode under RCU walk

    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
     

05 Mar, 2019

2 commits

  • The arg5 of KEYCTL_PKEY_QUERY should have a __user pointer tag on
    it as it is a user pointer. This clears the following sparse warning
    for this:

    security/keys/keyctl.c:1755:43: warning: incorrect type in argument 3 (different address spaces)
    security/keys/keyctl.c:1755:43: expected struct keyctl_pkey_query [noderef] *
    security/keys/keyctl.c:1755:43: got struct keyctl_pkey_query *

    Signed-off-by: Ben Dooks
    Acked-by: Serge Hallyn
    Signed-off-by: James Morris

    Ben Dooks
     
  • Every in-kernel use of this function defined it to KERNEL_DS (either as
    an actual define, or as an inline function). It's an entirely
    historical artifact, and long long long ago used to actually read the
    segment selector valueof '%ds' on x86.

    Which in the kernel is always KERNEL_DS.

    Inspired by a patch from Jann Horn that just did this for a very small
    subset of users (the ones in fs/), along with Al who suggested a script.
    I then just took it to the logical extreme and removed all the remaining
    gunk.

    Roughly scripted with

    git grep -l '(get_ds())' -- :^tools/ | xargs sed -i 's/(get_ds())/(KERNEL_DS)/'
    git grep -lw 'get_ds' -- :^tools/ | xargs sed -i '/^#define get_ds()/d'

    plus manual fixups to remove a few unusual usage patterns, the couple of
    inline function cases and to fix up a comment that had become stale.

    The 'get_ds()' function remains in an x86 kvm selftest, since in user
    space it actually does something relevant.

    Inspired-by: Jann Horn
    Inspired-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

02 Mar, 2019

1 commit


28 Feb, 2019

4 commits

  • new primitive: vfs_dup_fs_context(). Comes with fs_context
    method (->dup()) for copying the filesystem-specific parts
    of fs_context, along with LSM one (->fs_context_dup()) for
    doing the same to LSM parts.

    [needs better commit message, and change of Author:, anyway]

    Signed-off-by: Al Viro

    Al Viro
     
  • Implement filesystem context security hooks for the smack LSM.

    Signed-off-by: David Howells
    cc: Casey Schaufler
    cc: linux-security-module@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     
  • Implement the new mount API LSM hooks for SELinux. At some point the old
    hooks will need to be removed.

    Signed-off-by: David Howells
    cc: Paul Moore
    cc: Stephen Smalley
    cc: selinux@tycho.nsa.gov
    cc: linux-security-module@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     
  • Add LSM hooks for use by the new mount API and filesystem context code.
    This includes:

    (1) Hooks to handle allocation, duplication and freeing of the security
    record attached to a filesystem context.

    (2) A hook to snoop source specifications. There may be multiple of these
    if the filesystem supports it. They will to be local files/devices if
    fs_context::source_is_dev is true and will be something else, possibly
    remote server specifications, if false.

    (3) A hook to snoop superblock configuration options in key[=val] form.
    If the LSM decides it wants to handle it, it can suppress the option
    being passed to the filesystem. Note that 'val' may include commas
    and binary data with the fsopen patch.

    (4) A hook to perform validation and allocation after the configuration
    has been done but before the superblock is allocated and set up.

    (5) A hook to transfer the security from the context to a newly created
    superblock.

    (6) A hook to rule on whether a path point can be used as a mountpoint.

    These are intended to replace:

    security_sb_copy_data
    security_sb_kern_mount
    security_sb_mount
    security_sb_set_mnt_opts
    security_sb_clone_mnt_opts
    security_sb_parse_opts_str

    [AV -- some of the methods being replaced are already gone, some of the
    methods are not added for the lack of need]

    Signed-off-by: David Howells
    cc: linux-security-module@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     

26 Feb, 2019

2 commits


25 Feb, 2019

1 commit

  • Pull networking fixes from David Miller:
    "Hopefully the last pull request for this release. Fingers crossed:

    1) Only refcount ESP stats on full sockets, from Martin Willi.

    2) Missing barriers in AF_UNIX, from Al Viro.

    3) RCU protection fixes in ipv6 route code, from Paolo Abeni.

    4) Avoid false positives in untrusted GSO validation, from Willem de
    Bruijn.

    5) Forwarded mesh packets in mac80211 need more tailroom allocated,
    from Felix Fietkau.

    6) Use operstate consistently for linkup in team driver, from George
    Wilkie.

    7) ThunderX bug fixes from Vadim Lomovtsev. Mostly races between VF
    and PF code paths.

    8) Purge ipv6 exceptions during netdevice removal, from Paolo Abeni.

    9) nfp eBPF code gen fixes from Jiong Wang.

    10) bnxt_en firmware timeout fix from Michael Chan.

    11) Use after free in udp/udpv6 error handlers, from Paolo Abeni.

    12) Fix a race in x25_bind triggerable by syzbot, from Eric Dumazet"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (65 commits)
    net: phy: realtek: Dummy IRQ calls for RTL8366RB
    tcp: repaired skbs must init their tso_segs
    net/x25: fix a race in x25_bind()
    net: dsa: Remove documentation for port_fdb_prepare
    Revert "bridge: do not add port to router list when receives query with source 0.0.0.0"
    selftests: fib_tests: sleep after changing carrier. again.
    net: set static variable an initial value in atl2_probe()
    net: phy: marvell10g: Fix Multi-G advertisement to only advertise 10G
    bpf, doc: add bpf list as secondary entry to maintainers file
    udp: fix possible user after free in error handler
    udpv6: fix possible user after free in error handler
    fou6: fix proto error handler argument type
    udpv6: add the required annotation to mib type
    mdio_bus: Fix use-after-free on device_register fails
    net: Set rtm_table to RT_TABLE_COMPAT for ipv6 for tables > 255
    bnxt_en: Wait longer for the firmware message response to complete.
    bnxt_en: Fix typo in firmware message timeout logic.
    nfp: bpf: fix ALU32 high bits clearance bug
    nfp: bpf: fix code-gen bug on BPF_ALU | BPF_XOR | BPF_K
    Documentation: networking: switchdev: Update port parent ID section
    ...

    Linus Torvalds
     

23 Feb, 2019

2 commits

  • syzbot hit the 'BUG_ON(index_key->desc_len == 0);' in __key_link_begin()
    called from construct_alloc_key() during sys_request_key(), because the
    length of the key description was never calculated.

    The problem is that we rely on ->desc_len being initialized by
    search_process_keyrings(), specifically by search_nested_keyrings().
    But, if the process isn't subscribed to any keyrings that never happens.

    Fix it by always initializing keyring_index_key::desc_len as soon as the
    description is set, like we already do in some places.

    The following program reproduces the BUG_ON() when it's run as root and
    no session keyring has been installed. If it doesn't work, try removing
    pam_keyinit.so from /etc/pam.d/login and rebooting.

    #include
    #include
    #include

    int main(void)
    {
    int id = add_key("keyring", "syz", NULL, 0, KEY_SPEC_USER_KEYRING);

    keyctl_setperm(id, KEY_OTH_WRITE);
    setreuid(5000, 5000);
    request_key("user", "desc", "", id);
    }

    Reported-by: syzbot+ec24e95ea483de0a24da@syzkaller.appspotmail.com
    Fixes: b2a4df200d57 ("KEYS: Expand the capacity of a keyring")
    Signed-off-by: Eric Biggers
    Signed-off-by: David Howells
    Cc: stable@vger.kernel.org
    Signed-off-by: James Morris

    Eric Biggers
     
  • 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
     

22 Feb, 2019

1 commit

  • The SCTP sections were ending up at the top-level table of contents
    under the security section when they should have be sections with the
    SCTP chapters. In addition to correcting the section and subsection
    headings, this merges the SCTP documents into a single file to organize
    the chapters more clearly, internally linkifies them, and adds the
    missing SPDX header.

    Signed-off-by: Kees Cook
    Acked-by: Paul Moore
    Signed-off-by: Jonathan Corbet

    Kees Cook
     

21 Feb, 2019

1 commit

  • Several u->addr and u->path users are not holding any locks in
    common with unix_bind(). unix_state_lock() is useless for those
    purposes.

    u->addr is assign-once and *(u->addr) is fully set up by the time
    we set u->addr (all under unix_table_lock). u->path is also
    set in the same critical area, also before setting u->addr, and
    any unix_sock with ->path filled will have non-NULL ->addr.

    So setting ->addr with smp_store_release() is all we need for those
    "lockless" users - just have them fetch ->addr with smp_load_acquire()
    and don't even bother looking at ->path if they see NULL ->addr.

    Users of ->addr and ->path fall into several classes now:
    1) ones that do smp_load_acquire(u->addr) and access *(u->addr)
    and u->path only if smp_load_acquire() has returned non-NULL.
    2) places holding unix_table_lock. These are guaranteed that
    *(u->addr) is seen fully initialized. If unix_sock is in one of the
    "bound" chains, so's ->path.
    3) unix_sock_destructor() using ->addr is safe. All places
    that set u->addr are guaranteed to have seen all stores *(u->addr)
    while holding a reference to u and unix_sock_destructor() is called
    when (atomic) refcount hits zero.
    4) unix_release_sock() using ->path is safe. unix_bind()
    is serialized wrt unix_release() (normally - by struct file
    refcount), and for the instances that had ->path set by unix_bind()
    unix_release_sock() comes from unix_release(), so they are fine.
    Instances that had it set in unix_stream_connect() either end up
    attached to a socket (in unix_accept()), in which case the call
    chain to unix_release_sock() and serialization are the same as in
    the previous case, or they never get accept'ed and unix_release_sock()
    is called when the listener is shut down and its queue gets purged.
    In that case the listener's queue lock provides the barriers needed -
    unix_stream_connect() shoves our unix_sock into listener's queue
    under that lock right after having set ->path and eventual
    unix_release_sock() caller picks them from that queue under the
    same lock right before calling unix_release_sock().
    5) unix_find_other() use of ->path is pointless, but safe -
    it happens with successful lookup by (abstract) name, so ->path.dentry
    is guaranteed to be NULL there.

    earlier-variant-reviewed-by: "Paul E. McKenney"
    Signed-off-by: Al Viro
    Signed-off-by: David S. Miller

    Al Viro
     

20 Feb, 2019

1 commit


16 Feb, 2019

3 commits

  • Set the timestamp on new keys rather than leaving it unset.

    Fixes: 31d5a79d7f3d ("KEYS: Do LRU discard in full keyrings")
    Signed-off-by: David Howells
    Signed-off-by: James Morris

    David Howells
     
  • In the request_key() upcall mechanism there's a dependency loop by which if
    a key type driver overrides the ->request_key hook and the userspace side
    manages to lose the authorisation key, the auth key and the internal
    construction record (struct key_construction) can keep each other pinned.

    Fix this by the following changes:

    (1) Killing off the construction record and using the auth key instead.

    (2) Including the operation name in the auth key payload and making the
    payload available outside of security/keys/.

    (3) The ->request_key hook is given the authkey instead of the cons
    record and operation name.

    Changes (2) and (3) allow the auth key to naturally be cleaned up if the
    keyring it is in is destroyed or cleared or the auth key is unlinked.

    Fixes: 7ee02a316600 ("keys: Fix dependency loop between construction record and auth key")
    Signed-off-by: David Howells
    Signed-off-by: James Morris

    David Howells
     
  • If the sysctl 'kernel.keys.maxkeys' is set to some number n, then
    actually users can only add up to 'n - 1' keys. Likewise for
    'kernel.keys.maxbytes' and the root_* versions of these sysctls. But
    these sysctls are apparently supposed to be *maximums*, as per their
    names and all documentation I could find -- the keyrings(7) man page,
    Documentation/security/keys/core.rst, and all the mentions of EDQUOT
    meaning that the key quota was *exceeded* (as opposed to reached).

    Thus, fix the code to allow reaching the quotas exactly.

    Fixes: 0b77f5bfb45c ("keys: make the keyring quotas controllable through /proc/sys")
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Signed-off-by: David Howells
    Signed-off-by: James Morris

    Eric Biggers
     

15 Feb, 2019

1 commit

  • …ohar/linux-integrity into next-integrity

    From: Mimi Zohar <zohar@linux.ibm.com>

    Linux 5.0 introduced the platform keyring to allow verifying the IMA
    kexec kernel image signature using the pre-boot keys.  This pull
    request similarly makes keys on the platform keyring accessible for
    verifying the PE kernel image signature.*

    Also included in this pull request is a new IMA hook that tags tmp
    files, in policy, indicating the file hash needs to be calculated.
     The remaining patches are cleanup.

    *Upstream commit "993a110319a4 (x86/kexec: Fix a kexec_file_load()
    failure)" is required for testing.

    James Morris
     

14 Feb, 2019

1 commit

  • tpmdd updates for Linux v5.1

    From: Jarkko Sakkinen

    Clean up the transmission flow
    ==============================

    Cleaned up the whole transmission flow. Locking of the chip is now done in
    the level of tpm_try_get_ops() and tpm_put_ops() instead taking the chip
    lock inside tpm_transmit(). The nested calls inside tpm_transmit(), used
    with the resource manager, have been refactored out.

    Should make easier to perform more complex transactions with the TPM
    without making the subsystem a bigger mess (e.g. encrypted channel patches
    by James Bottomley).

    PPI 1.3 support
    ===============

    TPM PPI 1.3 introduces an additional optional command parameter that may be
    needed for some commands. Display the parameter if the command requires
    such a parameter. Only command 23 (SetPCRBanks) needs one.

    The PPI request file will show output like this then:

    # echo "23 16" > request
    # cat request
    23 16

    # echo "5" > request
    # cat request
    5

    Extend all PCR banks in IMA
    ===========================

    Instead of static PCR banks array, the array of available PCR banks is now
    allocated dynamically. The digests sizes are determined dynamically using a
    probe PCR read without relying crypto's static list of hash algorithms.

    This should finally make sealing of measurements in IMA safe and secure.

    TPM 2.0 selftests
    =================

    Added a test suite to tools/testing/selftests/tpm2 previously outside of
    the kernel tree: https://github.com/jsakkine-intel/tpm2-scripts.

    James Morris
     

13 Feb, 2019

4 commits

  • Currently, tpm_pcr_extend() accepts as an input only a SHA1 digest.

    This patch replaces the hash parameter of tpm_pcr_extend() with an array of
    tpm_digest structures, so that the caller can provide a digest for each PCR
    bank currently allocated in the TPM.

    tpm_pcr_extend() will not extend banks for which no digest was provided,
    as it happened before this patch, but instead it requires that callers
    provide the full set of digests. Since the number of digests will always be
    chip->nr_allocated_banks, the count parameter has been removed.

    Due to the API change, ima_pcr_extend() and pcrlock() have been modified.
    Since the number of allocated banks is not known in advance, the memory for
    the digests must be dynamically allocated. To avoid performance degradation
    and to avoid that a PCR extend is not done due to lack of memory, the array
    of tpm_digest structures is allocated by the users of the TPM driver at
    initialization time.

    Signed-off-by: Roberto Sassu
    Reviewed-by: Jarkko Sakkinen
    Tested-by: Jarkko Sakkinen
    Tested-by: Mimi Zohar (on x86 for TPM 1.2 & PTT TPM 2.0)
    Signed-off-by: Jarkko Sakkinen

    Roberto Sassu
     
  • When crypto agility support will be added to the TPM driver, users of the
    driver have to retrieve the allocated banks from chip->allocated_banks and
    use this information to prepare the array of tpm_digest structures to be
    passed to tpm_pcr_extend().

    This patch retrieves a tpm_chip pointer from tpm_default_chip() so that the
    pointer can be used to prepare the array of tpm_digest structures.

    Signed-off-by: Roberto Sassu
    Reviewed-by: Jarkko Sakkinen
    Tested-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen

    Roberto Sassu
     
  • Currently, the TPM driver retrieves the digest size from a table mapping
    TPM algorithms identifiers to identifiers defined by the crypto subsystem.
    If the algorithm is not defined by the latter, the digest size can be
    retrieved from the output of the PCR read command.

    The patch modifies the definition of tpm_pcr_read() and tpm2_pcr_read() to
    pass the desired hash algorithm and obtain the digest size at TPM startup.
    Algorithms and corresponding digest sizes are stored in the new structure
    tpm_bank_info, member of tpm_chip, so that the information can be used by
    other kernel subsystems.

    tpm_bank_info contains: the TPM algorithm identifier, necessary to generate
    the event log as defined by Trusted Computing Group (TCG); the digest size,
    to pad/truncate a digest calculated with a different algorithm; the crypto
    subsystem identifier, to calculate the digest of event data.

    This patch also protects against data corruption that could happen in the
    bus, by checking that the digest size returned by the TPM during a PCR read
    matches the size of the algorithm passed to tpm2_pcr_read().

    For the initial PCR read, when digest sizes are not yet available, this
    patch ensures that the amount of data copied from the output returned by
    the TPM does not exceed the size of the array data are copied to.

    Signed-off-by: Roberto Sassu
    Reviewed-by: Jarkko Sakkinen
    Tested-by: Jarkko Sakkinen
    Acked-by: Mimi Zohar
    Signed-off-by: Jarkko Sakkinen

    Roberto Sassu
     
  • In case of error, the function securityfs_create_dir() returns ERR_PTR()
    and never returns NULL. The NULL test in the return value check should
    be replaced with IS_ERR().

    Fixes: aeca4e2ca65c ("LSM: add SafeSetID module that gates setid calls")
    Signed-off-by: Wei Yongjun
    Acked-by: Kees Cook
    Signed-off-by: James Morris

    Wei Yongjun
     

06 Feb, 2019

1 commit

  • commit a2c513835bb6c6 ("selinux: inline some AVC functions used only once")
    introduced usage of audit_log_string() in place of audit_log_format()
    for fixed strings. However, audit_log_string() quotes the string.
    This breaks the avc audit message format and userspace audit parsers.
    Switch back to using audit_log_format().

    Fixes: a2c513835bb6c6 ("selinux: inline some AVC functions used only once")
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley