06 Apr, 2019

1 commit

  • [ Upstream commit 53e0c2aa9a59a48e3798ef193d573ade85aa80f5 ]

    Ignore all selinux_inode_notifysecctx() calls on mounts with SBLABEL_MNT
    flag unset. This is achived by returning -EOPNOTSUPP for this case in
    selinux_inode_setsecurtity() (because that function should not be called
    in such case anyway) and translating this error to 0 in
    selinux_inode_notifysecctx().

    This fixes behavior of kernfs-based filesystems when mounted with the
    'context=' option. Before this patch, if a node's context had been
    explicitly set to a non-default value and later the filesystem has been
    remounted with the 'context=' option, then this node would show up as
    having the manually-set context and not the mount-specified one.

    Steps to reproduce:
    # mount -t cgroup2 cgroup2 /sys/fs/cgroup/unified
    # chcon unconfined_u:object_r:user_home_t:s0 /sys/fs/cgroup/unified/cgroup.stat
    # ls -lZ /sys/fs/cgroup/unified
    total 0
    -r--r--r--. 1 root root system_u:object_r:cgroup_t:s0 0 Dec 13 10:41 cgroup.controllers
    -rw-r--r--. 1 root root system_u:object_r:cgroup_t:s0 0 Dec 13 10:41 cgroup.max.depth
    -rw-r--r--. 1 root root system_u:object_r:cgroup_t:s0 0 Dec 13 10:41 cgroup.max.descendants
    -rw-r--r--. 1 root root system_u:object_r:cgroup_t:s0 0 Dec 13 10:41 cgroup.procs
    -r--r--r--. 1 root root unconfined_u:object_r:user_home_t:s0 0 Dec 13 10:41 cgroup.stat
    -rw-r--r--. 1 root root system_u:object_r:cgroup_t:s0 0 Dec 13 10:41 cgroup.subtree_control
    -rw-r--r--. 1 root root system_u:object_r:cgroup_t:s0 0 Dec 13 10:41 cgroup.threads
    # umount /sys/fs/cgroup/unified
    # mount -o context=system_u:object_r:tmpfs_t:s0 -t cgroup2 cgroup2 /sys/fs/cgroup/unified

    Result before:
    # ls -lZ /sys/fs/cgroup/unified
    total 0
    -r--r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.controllers
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.max.depth
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.max.descendants
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.procs
    -r--r--r--. 1 root root unconfined_u:object_r:user_home_t:s0 0 Dec 13 10:41 cgroup.stat
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.subtree_control
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.threads

    Result after:
    # ls -lZ /sys/fs/cgroup/unified
    total 0
    -r--r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.controllers
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.max.depth
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.max.descendants
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.procs
    -r--r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.stat
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.subtree_control
    -rw-r--r--. 1 root root system_u:object_r:tmpfs_t:s0 0 Dec 13 10:41 cgroup.threads

    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Ondrej Mosnacek
     

24 Mar, 2019

2 commits

  • commit 3815a245b50124f0865415dcb606a034e97494d4 upstream.

    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
    Signed-off-by: Greg Kroah-Hartman

    J. Bruce Fields
     
  • commit 292c997a1970f8d1e1dfa354ed770a22f7b5a434 upstream.

    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
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

26 Jan, 2019

1 commit

  • [ Upstream commit 2cbdcb882f97a45f7475c67ac6257bbc16277dfe ]

    If a superblock has the MS_SUBMOUNT flag set, we should always allow
    mounting it. These mounts are done automatically by the kernel either as
    part of mounting some parent mount (e.g. debugfs always mounts tracefs
    under "tracing" for compatibility) or they are mounted automatically as
    needed on subdirectory accesses (e.g. NFS crossmnt mounts). Since such
    automounts are either an implicit consequence of the parent mount (which
    is already checked) or they can happen during regular accesses (where it
    doesn't make sense to check against the current task's context), the
    mount permission check should be skipped for them.

    Without this patch, attempts to access contents of an automounted
    directory can cause unexpected SELinux denials.

    In the current kernel tree, the MS_SUBMOUNT flag is set only via
    vfs_submount(), which is called only from the following places:
    - AFS, when automounting special "symlinks" referencing other cells
    - CIFS, when automounting "referrals"
    - NFS, when automounting subtrees
    - debugfs, when automounting tracefs

    In all cases the submounts are meant to be transparent to the user and
    it makes sense that if mounting the master is allowed, then so should be
    the automounts. Note that CAP_SYS_ADMIN capability checking is already
    skipped for (SB_KERNMOUNT|SB_SUBMOUNT) in:
    - sget_userns() in fs/super.c:
    if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) &&
    !(type->fs_flags & FS_USERNS_MOUNT) &&
    !capable(CAP_SYS_ADMIN))
    return ERR_PTR(-EPERM);
    - sget() in fs/super.c:
    /* Ensure the requestor has permissions over the target filesystem */
    if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN))
    return ERR_PTR(-EPERM);

    Verified internally on patched RHEL 7.6 with a reproducer using
    NFS+httpd and selinux-tesuite.

    Fixes: 93faccbbfa95 ("fs: Better permission checking for submounts")
    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Ondrej Mosnacek
     

23 Jan, 2019

1 commit

  • commit 5b0e7310a2a33c06edc7eb81ffc521af9b2c5610 upstream.

    levdatum->level can be NULL if we encounter an error while loading
    the policy during sens_read prior to initializing it. Make sure
    sens_destroy handles that case correctly.

    Reported-by: syzbot+6664500f0f18f07a5c0e@syzkaller.appspotmail.com
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Stephen Smalley
     

13 Jan, 2019

1 commit

  • commit 5df275cd4cf51c86d49009f1397132f284ba515e upstream.

    Do the LE conversions before doing the Infiniband-related range checks.
    The incorrect checks are otherwise causing a failure to load any policy
    with an ibendportcon rule on BE systems. This can be reproduced by
    running (on e.g. ppc64):

    cat >my_module.cil <
    Cc: Eli Cohen
    Cc: James Morris
    Cc: Doug Ledford
    Cc: # 4.13+
    Fixes: a806f7a1616f ("selinux: Create policydb version for Infiniband support")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Ondrej Mosnacek
     

08 Dec, 2018

1 commit

  • commit 598e1a42e9626213565d3b22ea948ce78556512a upstream.

    Commit 32a4f5ecd738 ("net: sched: introduce chain object to uapi")
    added new RTM_* definitions without properly updating SELinux, this
    patch adds the necessary SELinux support.

    While there was a BUILD_BUG_ON() in the SELinux code to protect from
    exactly this case, it was bypassed in the broken commit. In order to
    hopefully prevent this from happening in the future, add additional
    comments which provide some instructions on how to resolve the
    BUILD_BUG_ON() failures.

    Fixes: 32a4f5ecd738 ("net: sched: introduce chain object to uapi")
    Cc: # 4.19
    Acked-by: David S. Miller
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Paul Moore
     

01 Dec, 2018

1 commit

  • commit 4458bba09788e70e8fb39ad003f087cd9dfbd6ac upstream.

    syzbot is hitting warning at str_read() [1] because len parameter can
    become larger than KMALLOC_MAX_SIZE. We don't need to emit warning for
    this case.

    [1] https://syzkaller.appspot.com/bug?id=7f2f5aad79ea8663c296a2eedb81978401a908f0

    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     

21 Nov, 2018

1 commit

  • commit c138325fb8713472d5a0c3c7258b9131bab40725 upstream.

    selinux_sctp_bind_connect() must verify if the address buffer has
    sufficient length before accessing the 'sa_family' field. See
    __sctp_connect() for a similar check.

    The length of the whole address ('len') is already checked in the
    callees.

    Reported-by: Qian Cai
    Fixes: d452930fd3b9 ("selinux: Add SCTP support")
    Cc: # 4.17+
    Cc: Richard Haines
    Signed-off-by: Ondrej Mosnacek
    Tested-by: Qian Cai
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Ondrej Mosnacek
     

14 Nov, 2018

1 commit

  • commit 7bb185edb0306bb90029a5fa6b9cff900ffdbf4b upstream.

    commit 901ef845fa2469c ("selinux: allow per-file labeling for cgroupfs")
    broke mounting of cgroup2 under older SELinux policies which lacked
    a genfscon rule for cgroup2. This prevents mounting of cgroup2 even
    when SELinux is permissive.

    Change the handling when there is no genfscon rule in policy to
    just mark the inode unlabeled and not return an error to the caller.
    This permits mounting and access if allowed by policy, e.g. to
    unconfined domains.

    I also considered changing the behavior of security_genfs_sid() to
    never return -ENOENT, but the current behavior is relied upon by
    other callers to perform caller-specific handling.

    Fixes: 901ef845fa2469c ("selinux: allow per-file labeling for cgroupfs")
    CC:
    Reported-by: Dmitry Vyukov
    Reported-by: Waiman Long
    Signed-off-by: Stephen Smalley
    Tested-by: Waiman Long
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Stephen Smalley
     

16 Aug, 2018

3 commits

  • Pull networking updates from David Miller:
    "Highlights:

    - Gustavo A. R. Silva keeps working on the implicit switch fallthru
    changes.

    - Support 802.11ax High-Efficiency wireless in cfg80211 et al, From
    Luca Coelho.

    - Re-enable ASPM in r8169, from Kai-Heng Feng.

    - Add virtual XFRM interfaces, which avoids all of the limitations of
    existing IPSEC tunnels. From Steffen Klassert.

    - Convert GRO over to use a hash table, so that when we have many
    flows active we don't traverse a long list during accumluation.

    - Many new self tests for routing, TC, tunnels, etc. Too many
    contributors to mention them all, but I'm really happy to keep
    seeing this stuff.

    - Hardware timestamping support for dpaa_eth/fsl-fman from Yangbo Lu.

    - Lots of cleanups and fixes in L2TP code from Guillaume Nault.

    - Add IPSEC offload support to netdevsim, from Shannon Nelson.

    - Add support for slotting with non-uniform distribution to netem
    packet scheduler, from Yousuk Seung.

    - Add UDP GSO support to mlx5e, from Boris Pismenny.

    - Support offloading of Team LAG in NFP, from John Hurley.

    - Allow to configure TX queue selection based upon RX queue, from
    Amritha Nambiar.

    - Support ethtool ring size configuration in aquantia, from Anton
    Mikaev.

    - Support DSCP and flowlabel per-transport in SCTP, from Xin Long.

    - Support list based batching and stack traversal of SKBs, this is
    very exciting work. From Edward Cree.

    - Busyloop optimizations in vhost_net, from Toshiaki Makita.

    - Introduce the ETF qdisc, which allows time based transmissions. IGB
    can offload this in hardware. From Vinicius Costa Gomes.

    - Add parameter support to devlink, from Moshe Shemesh.

    - Several multiplication and division optimizations for BPF JIT in
    nfp driver, from Jiong Wang.

    - Lots of prepatory work to make more of the packet scheduler layer
    lockless, when possible, from Vlad Buslov.

    - Add ACK filter and NAT awareness to sch_cake packet scheduler, from
    Toke Høiland-Jørgensen.

    - Support regions and region snapshots in devlink, from Alex Vesker.

    - Allow to attach XDP programs to both HW and SW at the same time on
    a given device, with initial support in nfp. From Jakub Kicinski.

    - Add TLS RX offload and support in mlx5, from Ilya Lesokhin.

    - Use PHYLIB in r8169 driver, from Heiner Kallweit.

    - All sorts of changes to support Spectrum 2 in mlxsw driver, from
    Ido Schimmel.

    - PTP support in mv88e6xxx DSA driver, from Andrew Lunn.

    - Make TCP_USER_TIMEOUT socket option more accurate, from Jon
    Maxwell.

    - Support for templates in packet scheduler classifier, from Jiri
    Pirko.

    - IPV6 support in RDS, from Ka-Cheong Poon.

    - Native tproxy support in nf_tables, from Máté Eckl.

    - Maintain IP fragment queue in an rbtree, but optimize properly for
    in-order frags. From Peter Oskolkov.

    - Improvde handling of ACKs on hole repairs, from Yuchung Cheng"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1996 commits)
    bpf: test: fix spelling mistake "REUSEEPORT" -> "REUSEPORT"
    hv/netvsc: Fix NULL dereference at single queue mode fallback
    net: filter: mark expected switch fall-through
    xen-netfront: fix warn message as irq device name has '/'
    cxgb4: Add new T5 PCI device ids 0x50af and 0x50b0
    net: dsa: mv88e6xxx: missing unlock on error path
    rds: fix building with IPV6=m
    inet/connection_sock: prefer _THIS_IP_ to current_text_addr
    net: dsa: mv88e6xxx: bitwise vs logical bug
    net: sock_diag: Fix spectre v1 gadget in __sock_diag_cmd()
    ieee802154: hwsim: using right kind of iteration
    net: hns3: Add vlan filter setting by ethtool command -K
    net: hns3: Set tx ring' tc info when netdev is up
    net: hns3: Remove tx ring BD len register in hns3_enet
    net: hns3: Fix desc num set to default when setting channel
    net: hns3: Fix for phy link issue when using marvell phy driver
    net: hns3: Fix for information of phydev lost problem when down/up
    net: hns3: Fix for command format parsing error in hclge_is_all_function_id_zero
    net: hns3: Add support for serdes loopback selftest
    bnxt_en: take coredump_record structure off stack
    ...

    Linus Torvalds
     
  • Pull SELinux updates from Paul Moore:
    "There are 16 patches in here but really only one that is of any
    significance. That one patch is by nixiaoming and fixes a few places
    where we were not properly cleaning up dentry and inode objects in the
    selinuxfs error handling code. The rest are either printk->pr_*
    conversions, constification tweaks, and a minor tweak to MAINTAINERS.

    Everything passes the selinux-testsuite and looks to merge cleanly
    against your master branch"

    * tag 'selinux-pr-20180814' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: cleanup dentry and inodes on error in selinuxfs
    selinux: constify write_op[]
    selinux: Cleanup printk logging in netnode
    selinux: Cleanup printk logging in avc
    selinux: Cleanup printk logging in netif
    selinux: Cleanup printk logging in netport
    selinux: Cleanup printk logging in sidtab
    selinux: Cleanup printk logging in netlink
    selinux: Cleanup printk logging in selinuxfs
    selinux: Cleanup printk logging in services
    selinux: Cleanup printk logging in avtab
    selinux: Cleanup printk logging in hooks
    selinux: Cleanup printk logging in policydb
    selinux: Cleanup printk logging in ebitmap
    selinux: Cleanup printk logging in conditional
    MAINTAINERS: update the LSM and SELinux subsystems

    Linus Torvalds
     
  • Pull security subsystem updates from James Morris:

    - kstrdup() return value fix from Eric Biggers

    - Add new security_load_data hook to differentiate security checking of
    kernel-loaded binaries in the case of there being no associated file
    descriptor, from Mimi Zohar.

    - Add ability to IMA to specify a policy at build-time, rather than
    just via command line params or by loading a custom policy, from
    Mimi.

    - Allow IMA and LSMs to prevent sysfs firmware load fallback (e.g. if
    using signed firmware), from Mimi.

    - Allow IMA to deny loading of kexec kernel images, as they cannot be
    measured by IMA, from Mimi.

    * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    security: check for kstrdup() failure in lsm_append()
    security: export security_kernel_load_data function
    ima: based on policy warn about loading firmware (pre-allocated buffer)
    module: replace the existing LSM hook in init_module
    ima: add build time policy
    ima: based on policy require signed firmware (sysfs fallback)
    firmware: add call to LSM hook before firmware sysfs fallback
    ima: based on policy require signed kexec kernel images
    kexec: add call to LSM hook in original kexec_load syscall
    security: define new LSM hook named security_kernel_load_data
    MAINTAINERS: remove the outdated "LINUX SECURITY MODULE (LSM) FRAMEWORK" entry

    Linus Torvalds
     

14 Aug, 2018

1 commit

  • Pull vfs open-related updates from Al Viro:

    - "do we need fput() or put_filp()" rules are gone - it's always fput()
    now. We keep track of that state where it belongs - in ->f_mode.

    - int *opened mess killed - in finish_open(), in ->atomic_open()
    instances and in fs/namei.c code around do_last()/lookup_open()/atomic_open().

    - alloc_file() wrappers with saner calling conventions are introduced
    (alloc_file_clone() and alloc_file_pseudo()); callers converted, with
    much simplification.

    - while we are at it, saner calling conventions for path_init() and
    link_path_walk(), simplifying things inside fs/namei.c (both on
    open-related paths and elsewhere).

    * 'work.open3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (40 commits)
    few more cleanups of link_path_walk() callers
    allow link_path_walk() to take ERR_PTR()
    make path_init() unconditionally paired with terminate_walk()
    document alloc_file() changes
    make alloc_file() static
    do_shmat(): grab shp->shm_file earlier, switch to alloc_file_clone()
    new helper: alloc_file_clone()
    create_pipe_files(): switch the first allocation to alloc_file_pseudo()
    anon_inode_getfile(): switch to alloc_file_pseudo()
    hugetlb_file_setup(): switch to alloc_file_pseudo()
    ocxlflash_getfile(): switch to alloc_file_pseudo()
    cxl_getfile(): switch to alloc_file_pseudo()
    ... and switch shmem_file_setup() to alloc_file_pseudo()
    __shmem_file_setup(): reorder allocations
    new wrapper: alloc_file_pseudo()
    kill FILE_{CREATED,OPENED}
    switch atomic_open() and lookup_open() to returning 0 in all success cases
    document ->atomic_open() changes
    ->atomic_open(): return 0 in all success cases
    get rid of 'opened' in path_openat() and the helpers downstream
    ...

    Linus Torvalds
     

08 Aug, 2018

1 commit

  • If the resource requested by d_alloc_name is not added to the linked
    list through d_add, then dput needs to be called to release the
    subsequent abnormal branch to avoid resource leakage.

    Add missing dput to selinuxfs.c

    Signed-off-by: nixiaoming
    [PM: tweak the subject line]
    Signed-off-by: Paul Moore

    nixiaoming
     

24 Jul, 2018

1 commit

  • Allow user to create, destroy, get and dump chain objects. Do that by
    extending rtnl commands by the chain-specific ones. User will now be
    able to explicitly create or destroy chains (so far this was done only
    automatically according the filter/act needs and refcounting). Also, the
    user will receive notification about any chain creation or destuction.

    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Jiri Pirko
     

18 Jul, 2018

1 commit


17 Jul, 2018

1 commit

  • Both the init_module and finit_module syscalls call either directly
    or indirectly the security_kernel_read_file LSM hook. This patch
    replaces the direct call in init_module with a call to the new
    security_kernel_load_data hook and makes the corresponding changes
    in SELinux, LoadPin, and IMA.

    Signed-off-by: Mimi Zohar
    Cc: Jeff Vander Stoep
    Cc: Casey Schaufler
    Cc: Kees Cook
    Acked-by: Jessica Yu
    Acked-by: Paul Moore
    Acked-by: Kees Cook
    Signed-off-by: James Morris

    Mimi Zohar
     

12 Jul, 2018

1 commit


01 Jul, 2018

1 commit


29 Jun, 2018

1 commit

  • If a user is accessing a file in selinuxfs with a pointer to a userspace
    buffer that is backed by e.g. a userfaultfd, the userspace access can
    stall indefinitely, which can block fsi->mutex if it is held.

    For sel_read_policy(), remove the locking, since this method doesn't seem
    to access anything that requires locking.

    For sel_read_bool(), move the user access below the locked region.

    For sel_write_bool() and sel_commit_bools_write(), move the user access
    up above the locked region.

    Cc: stable@vger.kernel.org
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Jann Horn
    Acked-by: Stephen Smalley
    [PM: removed an unused variable in sel_read_policy()]
    Signed-off-by: Paul Moore

    Jann Horn
     

20 Jun, 2018

11 commits


19 Jun, 2018

2 commits


16 Jun, 2018

1 commit

  • As we move stuff around, some doc references are broken. Fix some of
    them via this script:
    ./scripts/documentation-file-ref-check --fix

    Manually checked if the produced result is valid, removing a few
    false-positives.

    Acked-by: Takashi Iwai
    Acked-by: Masami Hiramatsu
    Acked-by: Stephen Boyd
    Acked-by: Charles Keepax
    Acked-by: Mathieu Poirier
    Reviewed-by: Coly Li
    Signed-off-by: Mauro Carvalho Chehab
    Acked-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

07 Jun, 2018

4 commits

  • Pull networking updates from David Miller:

    1) Add Maglev hashing scheduler to IPVS, from Inju Song.

    2) Lots of new TC subsystem tests from Roman Mashak.

    3) Add TCP zero copy receive and fix delayed acks and autotuning with
    SO_RCVLOWAT, from Eric Dumazet.

    4) Add XDP_REDIRECT support to mlx5 driver, from Jesper Dangaard
    Brouer.

    5) Add ttl inherit support to vxlan, from Hangbin Liu.

    6) Properly separate ipv6 routes into their logically independant
    components. fib6_info for the routing table, and fib6_nh for sets of
    nexthops, which thus can be shared. From David Ahern.

    7) Add bpf_xdp_adjust_tail helper, which can be used to generate ICMP
    messages from XDP programs. From Nikita V. Shirokov.

    8) Lots of long overdue cleanups to the r8169 driver, from Heiner
    Kallweit.

    9) Add BTF ("BPF Type Format"), from Martin KaFai Lau.

    10) Add traffic condition monitoring to iwlwifi, from Luca Coelho.

    11) Plumb extack down into fib_rules, from Roopa Prabhu.

    12) Add Flower classifier offload support to igb, from Vinicius Costa
    Gomes.

    13) Add UDP GSO support, from Willem de Bruijn.

    14) Add documentation for eBPF helpers, from Quentin Monnet.

    15) Add TLS tx offload to mlx5, from Ilya Lesokhin.

    16) Allow applications to be given the number of bytes available to read
    on a socket via a control message returned from recvmsg(), from
    Soheil Hassas Yeganeh.

    17) Add x86_32 eBPF JIT compiler, from Wang YanQing.

    18) Add AF_XDP sockets, with zerocopy support infrastructure as well.
    From Björn Töpel.

    19) Remove indirect load support from all of the BPF JITs and handle
    these operations in the verifier by translating them into native BPF
    instead. From Daniel Borkmann.

    20) Add GRO support to ipv6 gre tunnels, from Eran Ben Elisha.

    21) Allow XDP programs to do lookups in the main kernel routing tables
    for forwarding. From David Ahern.

    22) Allow drivers to store hardware state into an ELF section of kernel
    dump vmcore files, and use it in cxgb4. From Rahul Lakkireddy.

    23) Various RACK and loss detection improvements in TCP, from Yuchung
    Cheng.

    24) Add TCP SACK compression, from Eric Dumazet.

    25) Add User Mode Helper support and basic bpfilter infrastructure, from
    Alexei Starovoitov.

    26) Support ports and protocol values in RTM_GETROUTE, from Roopa
    Prabhu.

    27) Support bulking in ->ndo_xdp_xmit() API, from Jesper Dangaard
    Brouer.

    28) Add lots of forwarding selftests, from Petr Machata.

    29) Add generic network device failover driver, from Sridhar Samudrala.

    * ra.kernel.org:/pub/scm/linux/kernel/git/davem/net-next: (1959 commits)
    strparser: Add __strp_unpause and use it in ktls.
    rxrpc: Fix terminal retransmission connection ID to include the channel
    net: hns3: Optimize PF CMDQ interrupt switching process
    net: hns3: Fix for VF mailbox receiving unknown message
    net: hns3: Fix for VF mailbox cannot receiving PF response
    bnx2x: use the right constant
    Revert "net: sched: cls: Fix offloading when ingress dev is vxlan"
    net: dsa: b53: Fix for brcm tag issue in Cygnus SoC
    enic: fix UDP rss bits
    netdev-FAQ: clarify DaveM's position for stable backports
    rtnetlink: validate attributes in do_setlink()
    mlxsw: Add extack messages for port_{un, }split failures
    netdevsim: Add extack error message for devlink reload
    devlink: Add extack to reload and port_{un, }split operations
    net: metrics: add proper netlink validation
    ipmr: fix error path when ipmr_new_table fails
    ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds
    net: hns3: remove unused hclgevf_cfg_func_mta_filter
    netfilter: provide udp*_lib_lookup for nf_tproxy
    qed*: Utilize FW 8.37.2.0
    ...

    Linus Torvalds
     
  • Pull audit updates from Paul Moore:
    "Another reasonable chunk of audit changes for v4.18, thirteen patches
    in total.

    The thirteen patches can mostly be broken down into one of four
    categories: general bug fixes, accessor functions for audit state
    stored in the task_struct, negative filter matches on executable
    names, and extending the (relatively) new seccomp logging knobs to the
    audit subsystem.

    The main driver for the accessor functions from Richard are the
    changes we're working on to associate audit events with containers,
    but I think they have some standalone value too so I figured it would
    be good to get them in now.

    The seccomp/audit patches from Tyler apply the seccomp logging
    improvements from a few releases ago to audit's seccomp logging;
    starting with this patchset the changes in
    /proc/sys/kernel/seccomp/actions_logged should apply to both the
    standard kernel logging and audit.

    As usual, everything passes the audit-testsuite and it happens to
    merge cleanly with your tree"

    [ Heh, except it had trivial merge conflicts with the SELinux tree that
    also came in from Paul - Linus ]

    * tag 'audit-pr-20180605' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: Fix wrong task in comparison of session ID
    audit: use existing session info function
    audit: normalize loginuid read access
    audit: use new audit_context access funciton for seccomp_actions_logged
    audit: use inline function to set audit context
    audit: use inline function to get audit context
    audit: convert sessionid unset to a macro
    seccomp: Don't special case audited processes when logging
    seccomp: Audit attempts to modify the actions_logged sysctl
    seccomp: Configurable separator for the actions_logged string
    seccomp: Separate read and write code for actions_logged sysctl
    audit: allow not equal op for audit by executable
    audit: add syscall information to FEATURE_CHANGE records

    Linus Torvalds
     
  • Pull SELinux updates from Paul Moore:
    "SELinux is back with a quiet pull request for v4.18. Three patches,
    all small: two cleanups of the SELinux audit records, and one to
    migrate to a newly defined type (vm_fault_t).

    Everything passes our test suite, and as of about five minutes ago it
    merged cleanly with your tree"

    * tag 'selinux-pr-20180605' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    audit: normalize MAC_POLICY_LOAD record
    audit: normalize MAC_STATUS record
    security: selinux: Change return type to vm_fault_t

    Linus Torvalds
     
  • Pull security system updates from James Morris:

    - incorporate new socketpair() hook into LSM and wire up the SELinux
    and Smack modules. From David Herrmann:

    "The idea is to allow SO_PEERSEC to be called on AF_UNIX sockets
    created via socketpair(2), and return the same information as if
    you emulated socketpair(2) via a temporary listener socket.

    Right now SO_PEERSEC will return the unlabeled credentials for a
    socketpair, rather than the actual credentials of the creating
    process."

    - remove the unused security_settime LSM hook (Sargun Dhillon).

    - remove some stack allocated arrays from the keys code (Tycho
    Andersen)

    * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    dh key: get rid of stack allocated array for zeroes
    dh key: get rid of stack allocated array
    big key: get rid of stack array allocation
    smack: provide socketpair callback
    selinux: provide socketpair callback
    net: hook socketpair() into LSM
    security: add hook for socketpair()
    security: remove security_settime

    Linus Torvalds