22 Nov, 2020

1 commit

  • Child sockets erroneously inherit their parent's sk_type (ie. SOCK_*),
    instead of the PF_IUCV protocol that the parent was created with in
    iucv_sock_create().

    We're currently not using sk->sk_protocol ourselves, so this shouldn't
    have much impact (except eg. getting the output in skb_dump() right).

    Fixes: eac3731bd04c ("[S390]: Add AF_IUCV socket support")
    Signed-off-by: Julian Wiedmann
    Link: https://lore.kernel.org/r/20201120100657.34407-1-jwi@linux.ibm.com
    Signed-off-by: Jakub Kicinski

    Julian Wiedmann
     

11 Nov, 2020

1 commit

  • syzbot reported the following KASAN finding:

    BUG: KASAN: nullptr-dereference in iucv_send_ctrl+0x390/0x3f0 net/iucv/af_iucv.c:385
    Read of size 2 at addr 000000000000021e by task syz-executor907/519

    CPU: 0 PID: 519 Comm: syz-executor907 Not tainted 5.9.0-syzkaller-07043-gbcf9877ad213 #0
    Hardware name: IBM 3906 M04 701 (KVM/Linux)
    Call Trace:
    [] unwind_start arch/s390/include/asm/unwind.h:65 [inline]
    [] show_stack+0x180/0x228 arch/s390/kernel/dumpstack.c:135
    [] __dump_stack lib/dump_stack.c:77 [inline]
    [] dump_stack+0x268/0x2f0 lib/dump_stack.c:118
    [] print_address_description.constprop.0+0x5e/0x218 mm/kasan/report.c:383
    [] __kasan_report mm/kasan/report.c:517 [inline]
    [] kasan_report+0x11a/0x168 mm/kasan/report.c:534
    [] iucv_send_ctrl+0x390/0x3f0 net/iucv/af_iucv.c:385
    [] iucv_sock_shutdown+0x44a/0x4c0 net/iucv/af_iucv.c:1457
    [] __sys_shutdown+0x12c/0x1c8 net/socket.c:2204
    [] __do_sys_shutdown net/socket.c:2212 [inline]
    [] __s390x_sys_shutdown+0x38/0x48 net/socket.c:2210
    [] system_call+0xe0/0x28c arch/s390/kernel/entry.S:415

    There is nothing to shutdown if a connection has never been established.
    Besides that iucv->hs_dev is not yet initialized if a socket is in
    IUCV_OPEN state and iucv->path is not yet initialized if socket is in
    IUCV_BOUND state.
    So, just skip the shutdown calls for a socket in these states.

    Fixes: eac3731bd04c ("[S390]: Add AF_IUCV socket support")
    Fixes: 82492a355fac ("af_iucv: add shutdown for HS transport")
    Reviewed-by: Vasily Gorbik
    Signed-off-by: Ursula Braun
    [jwi: correct one Fixes tag]
    Signed-off-by: Julian Wiedmann
    Signed-off-by: Jakub Kicinski

    Ursula Braun
     

04 Oct, 2020

2 commits

  • smatch complains about
    net/iucv/iucv.c:1119 __iucv_message_receive() warn: inconsistent indenting

    While touching this line, also make the return logic consistent and thus
    get rid of a goto label.

    Signed-off-by: Julian Wiedmann
    Reviewed-by: Karsten Graul
    Signed-off-by: David S. Miller

    Julian Wiedmann
     
  • smatch complains about
    net/iucv/af_iucv.c:624 iucv_sock_bind() error: memcpy() 'sa->siucv_user_id' too small (8 vs 9)

    Which is absolutely correct - the memcpy() takes 9 bytes (sizeof(uid))
    from an 8-byte field (sa->siucv_user_id).
    Luckily the sockaddr_iucv struct contains more data after the
    .siucv_user_id field, and we checked the size of the passed data earlier
    on. So the memcpy() won't accidentally read from an invalid location.

    Fix the warning by reducing the size of the uid variable to what's
    actually needed, and thus reducing the amount of copied data.

    Signed-off-by: Julian Wiedmann
    Reviewed-by: Karsten Graul
    Signed-off-by: David S. Miller

    Julian Wiedmann
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

06 Aug, 2020

1 commit

  • Pull networking updates from David Miller:

    1) Support 6Ghz band in ath11k driver, from Rajkumar Manoharan.

    2) Support UDP segmentation in code TSO code, from Eric Dumazet.

    3) Allow flashing different flash images in cxgb4 driver, from Vishal
    Kulkarni.

    4) Add drop frames counter and flow status to tc flower offloading,
    from Po Liu.

    5) Support n-tuple filters in cxgb4, from Vishal Kulkarni.

    6) Various new indirect call avoidance, from Eric Dumazet and Brian
    Vazquez.

    7) Fix BPF verifier failures on 32-bit pointer arithmetic, from
    Yonghong Song.

    8) Support querying and setting hardware address of a port function via
    devlink, use this in mlx5, from Parav Pandit.

    9) Support hw ipsec offload on bonding slaves, from Jarod Wilson.

    10) Switch qca8k driver over to phylink, from Jonathan McDowell.

    11) In bpftool, show list of processes holding BPF FD references to
    maps, programs, links, and btf objects. From Andrii Nakryiko.

    12) Several conversions over to generic power management, from Vaibhav
    Gupta.

    13) Add support for SO_KEEPALIVE et al. to bpf_setsockopt(), from Dmitry
    Yakunin.

    14) Various https url conversions, from Alexander A. Klimov.

    15) Timestamping and PHC support for mscc PHY driver, from Antoine
    Tenart.

    16) Support bpf iterating over tcp and udp sockets, from Yonghong Song.

    17) Support 5GBASE-T i40e NICs, from Aleksandr Loktionov.

    18) Add kTLS RX HW offload support to mlx5e, from Tariq Toukan.

    19) Fix the ->ndo_start_xmit() return type to be netdev_tx_t in several
    drivers. From Luc Van Oostenryck.

    20) XDP support for xen-netfront, from Denis Kirjanov.

    21) Support receive buffer autotuning in MPTCP, from Florian Westphal.

    22) Support EF100 chip in sfc driver, from Edward Cree.

    23) Add XDP support to mvpp2 driver, from Matteo Croce.

    24) Support MPTCP in sock_diag, from Paolo Abeni.

    25) Commonize UDP tunnel offloading code by creating udp_tunnel_nic
    infrastructure, from Jakub Kicinski.

    26) Several pci_ --> dma_ API conversions, from Christophe JAILLET.

    27) Add FLOW_ACTION_POLICE support to mlxsw, from Ido Schimmel.

    28) Add SK_LOOKUP bpf program type, from Jakub Sitnicki.

    29) Refactor a lot of networking socket option handling code in order to
    avoid set_fs() calls, from Christoph Hellwig.

    30) Add rfc4884 support to icmp code, from Willem de Bruijn.

    31) Support TBF offload in dpaa2-eth driver, from Ioana Ciornei.

    32) Support XDP_REDIRECT in qede driver, from Alexander Lobakin.

    33) Support PCI relaxed ordering in mlx5 driver, from Aya Levin.

    34) Support TCP syncookies in MPTCP, from Flowian Westphal.

    35) Fix several tricky cases of PMTU handling wrt. briding, from Stefano
    Brivio.

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2056 commits)
    net: thunderx: initialize VF's mailbox mutex before first usage
    usb: hso: remove bogus check for EINPROGRESS
    usb: hso: no complaint about kmalloc failure
    hso: fix bailout in error case of probe
    ip_tunnel_core: Fix build for archs without _HAVE_ARCH_IPV6_CSUM
    selftests/net: relax cpu affinity requirement in msg_zerocopy test
    mptcp: be careful on subflow creation
    selftests: rtnetlink: make kci_test_encap() return sub-test result
    selftests: rtnetlink: correct the final return value for the test
    net: dsa: sja1105: use detected device id instead of DT one on mismatch
    tipc: set ub->ifindex for local ipv6 address
    ipv6: add ipv6_dev_find()
    net: openvswitch: silence suspicious RCU usage warning
    Revert "vxlan: fix tos value before xmit"
    ptp: only allow phase values lower than 1 period
    farsync: switch from 'pci_' to 'dma_' API
    wan: wanxl: switch from 'pci_' to 'dma_' API
    hv_netvsc: do not use VF device if link is down
    dpaa2-eth: Fix passing zero to 'PTR_ERR' warning
    net: macb: Properly handle phylink on at91sam9x
    ...

    Linus Torvalds
     

31 Jul, 2020

1 commit

  • This converts all the existing DECLARE_TASKLET() (and ...DISABLED)
    macros with DECLARE_TASKLET_OLD() in preparation for refactoring the
    tasklet callback type. All existing DECLARE_TASKLET() users had a "0"
    data argument, it has been removed here as well.

    Reviewed-by: Greg Kroah-Hartman
    Acked-by: Thomas Gleixner
    Signed-off-by: Kees Cook

    Kees Cook
     

25 Jul, 2020

1 commit

  • Rework the remaining setsockopt code to pass a sockptr_t instead of a
    plain user pointer. This removes the last remaining set_fs(KERNEL_DS)
    outside of architecture specific code.

    Signed-off-by: Christoph Hellwig
    Acked-by: Stefan Schmidt [ieee802154]
    Acked-by: Matthieu Baerts
    Signed-off-by: David S. Miller

    Christoph Hellwig
     

20 May, 2020

5 commits


10 Dec, 2019

1 commit

  • Replace all the occurrences of FIELD_SIZEOF() with sizeof_field() except
    at places where these are defined. Later patches will remove the unused
    definition of FIELD_SIZEOF().

    This patch is generated using following script:

    EXCLUDE_FILES="include/linux/stddef.h|include/linux/kernel.h"

    git grep -l -e "\bFIELD_SIZEOF\b" | while read file;
    do

    if [[ "$file" =~ $EXCLUDE_FILES ]]; then
    continue
    fi
    sed -i -e 's/\bFIELD_SIZEOF\b/sizeof_field/g' $file;
    done

    Signed-off-by: Pankaj Bharadiya
    Link: https://lore.kernel.org/r/20190924105839.110713-3-pankaj.laxminarayan.bharadiya@intel.com
    Co-developed-by: Kees Cook
    Signed-off-by: Kees Cook
    Acked-by: David Miller # for net

    Pankaj Bharadiya
     

30 Jul, 2019

1 commit

  • Mark switch cases where we are expecting to fall through.

    This patch fixes the following warnings:

    net/iucv/af_iucv.c: warning: this statement may fall
    through [-Wimplicit-fallthrough=]: => 537:3, 519:6, 2246:6, 510:6

    Notice that, in this particular case, the code comment is
    modified in accordance with what GCC is expecting to find.

    Reported-by: Geert Uytterhoeven
    Signed-off-by: Gustavo A. R. Silva
    Reviewed-by: Kees Cook
    Signed-off-by: David S. Miller

    Gustavo A. R. Silva
     

20 Jun, 2019

3 commits

  • Even when running as VM guest (ie pr_iucv != NULL), af_iucv can still
    open HiperTransport-based connections. For robust operation these
    connections require the af_iucv_netdev_notifier, so register it
    unconditionally.

    Also handle any error that register_netdevice_notifier() returns.

    Fixes: 9fbd87d41392 ("af_iucv: handle netdev events")
    Signed-off-by: Julian Wiedmann
    Reviewed-by: Ursula Braun
    Signed-off-by: David S. Miller

    Julian Wiedmann
     
  • The HiperSockets-based transport path in af_iucv is still too closely
    entangled with qeth.
    With commit a647a02512ca ("s390/qeth: speed-up L3 IQD xmit"), the
    relevant xmit code in qeth has begun to use skb_cow_head(). So to avoid
    unnecessary skb head expansions, af_iucv must learn to
    1) respect dev->needed_headroom when allocating skbs, and
    2) drop the header reference before cloning the skb.

    While at it, also stop hard-coding the LL-header creation stage and just
    use the appropriate helper.

    Fixes: a647a02512ca ("s390/qeth: speed-up L3 IQD xmit")
    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Julian Wiedmann
     
  • af_iucv sockets over z/VM IUCV require that their skbs are allocated
    in DMA memory. This restriction doesn't apply to connections over
    HiperSockets. So only set this limit for z/VM IUCV sockets, thereby
    increasing the likelihood that the large (and linear!) allocations for
    HiperTransport messages succeed.

    Fixes: 3881ac441f64 ("af_iucv: add HiperSockets transport")
    Signed-off-by: Julian Wiedmann
    Reviewed-by: Ursula Braun
    Reviewed-by: Hendrik Brueckner
    Signed-off-by: David S. Miller

    Julian Wiedmann
     

31 May, 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 either version 2 or at your option any
    later version this program is distributed in the hope that it will
    be useful but without any warranty without even the implied warranty
    of merchantability or fitness for a particular purpose see the gnu
    general public license for more details you should have received a
    copy of the gnu general public license along with this program if
    not write to the free software foundation inc 675 mass ave cambridge
    ma 02139 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     

21 May, 2019

2 commits


11 Nov, 2018

1 commit

  • Eliminate the assumption that SKBs and SKB list heads can
    be cast to eachother in SKB list handling code.

    This change also appears to fix a bug since the list->next pointer is
    sampled outside of holding the SKB queue lock.

    Signed-off-by: David S. Miller

    David S. Miller
     

24 Oct, 2018

1 commit

  • This reverts commit dd979b4df817e9976f18fb6f9d134d6bc4a3c317.

    This broke tcp_poll for SMC fallback: An AF_SMC socket establishes an
    internal TCP socket for the initial handshake with the remote peer.
    Whenever the SMC connection can not be established this TCP socket is
    used as a fallback. All socket operations on the SMC socket are then
    forwarded to the TCP socket. In case of poll, the file->private_data
    pointer references the SMC socket because the TCP socket has no file
    assigned. This causes tcp_poll to wait on the wrong socket.

    Signed-off-by: Karsten Graul
    Signed-off-by: David S. Miller

    Karsten Graul
     

27 Sep, 2018

1 commit

  • This patch attempts to untangle the TX and RX code in qeth from
    af_iucv's respective HiperTransport path:
    On the TX side, pointing skb_network_header() at the IUCV header
    means that qeth_l3_fill_af_iucv_hdr() no longer needs a magical offset
    to access the header.
    On the RX side, qeth pulls the (fake) L2 header off the skb like any
    normal ethernet driver would. This makes working with the IUCV header
    in af_iucv easier, since we no longer have to assume a fixed skb layout.

    While at it, replace the open-coded length checks in af_iucv's RX path
    with pskb_may_pull().

    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Julian Wiedmann
     

20 Sep, 2018

1 commit


06 Sep, 2018

3 commits

  • Fixes a compile warning.

    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Julian Wiedmann
     
  • When sending an skb, afiucv_hs_send() bails out on various error
    conditions. But currently the caller has no way of telling whether the
    skb was freed or not - resulting in potentially either
    a) leaked skbs from iucv_send_ctrl(), or
    b) double-free's from iucv_sock_sendmsg().

    As dev_queue_xmit() will always consume the skb (even on error), be
    consistent and also free the skb from all other error paths. This way
    callers no longer need to care about managing the skb.

    Signed-off-by: Julian Wiedmann
    Reviewed-by: Ursula Braun
    Signed-off-by: David S. Miller

    Julian Wiedmann
     
  • Inbound packets may have any combination of flag bits set in their iucv
    header. If we don't know how to handle a specific combination, drop the
    skb instead of leaking it.

    To clarify what error is returned in this case, replace the hard-coded
    0 with the corresponding macro.

    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Julian Wiedmann
     

09 Aug, 2018

1 commit


31 Jul, 2018

1 commit


25 Jul, 2018

1 commit


29 Jun, 2018

1 commit

  • The poll() changes were not well thought out, and completely
    unexplained. They also caused a huge performance regression, because
    "->poll()" was no longer a trivial file operation that just called down
    to the underlying file operations, but instead did at least two indirect
    calls.

    Indirect calls are sadly slow now with the Spectre mitigation, but the
    performance problem could at least be largely mitigated by changing the
    "->get_poll_head()" operation to just have a per-file-descriptor pointer
    to the poll head instead. That gets rid of one of the new indirections.

    But that doesn't fix the new complexity that is completely unwarranted
    for the regular case. The (undocumented) reason for the poll() changes
    was some alleged AIO poll race fixing, but we don't make the common case
    slower and more complex for some uncommon special case, so this all
    really needs way more explanations and most likely a fundamental
    redesign.

    [ This revert is a revert of about 30 different commits, not reverted
    individually because that would just be unnecessarily messy - Linus ]

    Cc: Al Viro
    Cc: Christoph Hellwig
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

26 May, 2018

1 commit


23 Mar, 2018

1 commit

  • Fun set of conflict resolutions here...

    For the mac80211 stuff, these were fortunately just parallel
    adds. Trivially resolved.

    In drivers/net/phy/phy.c we had a bug fix in 'net' that moved the
    function phy_disable_interrupts() earlier in the file, whilst in
    'net-next' the phy_error() call from this function was removed.

    In net/ipv4/xfrm4_policy.c, David Ahern's changes to remove the
    'rt_table_id' member of rtable collided with a bug fix in 'net' that
    added a new struct member "rt_mtu_locked" which needs to be copied
    over here.

    The mlxsw driver conflict consisted of net-next separating
    the span code and definitions into separate files, whilst
    a 'net' bug fix made some changes to that moved code.

    The mlx5 infiniband conflict resolution was quite non-trivial,
    the RDMA tree's merge commit was used as a guide here, and
    here are their notes:

    ====================

    Due to bug fixes found by the syzkaller bot and taken into the for-rc
    branch after development for the 4.17 merge window had already started
    being taken into the for-next branch, there were fairly non-trivial
    merge issues that would need to be resolved between the for-rc branch
    and the for-next branch. This merge resolves those conflicts and
    provides a unified base upon which ongoing development for 4.17 can
    be based.

    Conflicts:
    drivers/infiniband/hw/mlx5/main.c - Commit 42cea83f9524
    (IB/mlx5: Fix cleanup order on unload) added to for-rc and
    commit b5ca15ad7e61 (IB/mlx5: Add proper representors support)
    add as part of the devel cycle both needed to modify the
    init/de-init functions used by mlx5. To support the new
    representors, the new functions added by the cleanup patch
    needed to be made non-static, and the init/de-init list
    added by the representors patch needed to be modified to
    match the init/de-init list changes made by the cleanup
    patch.
    Updates:
    drivers/infiniband/hw/mlx5/mlx5_ib.h - Update function
    prototypes added by representors patch to reflect new function
    names as changed by cleanup patch
    drivers/infiniband/hw/mlx5/ib_rep.c - Update init/de-init
    stage list to match new order from cleanup patch
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

16 Mar, 2018

1 commit


13 Feb, 2018

1 commit

  • Changes since v1:
    Added changes in these files:
    drivers/infiniband/hw/usnic/usnic_transport.c
    drivers/staging/lustre/lnet/lnet/lib-socket.c
    drivers/target/iscsi/iscsi_target_login.c
    drivers/vhost/net.c
    fs/dlm/lowcomms.c
    fs/ocfs2/cluster/tcp.c
    security/tomoyo/network.c

    Before:
    All these functions either return a negative error indicator,
    or store length of sockaddr into "int *socklen" parameter
    and return zero on success.

    "int *socklen" parameter is awkward. For example, if caller does not
    care, it still needs to provide on-stack storage for the value
    it does not need.

    None of the many FOO_getname() functions of various protocols
    ever used old value of *socklen. They always just overwrite it.

    This change drops this parameter, and makes all these functions, on success,
    return length of sockaddr. It's always >= 0 and can be differentiated
    from an error.

    Tests in callers are changed from "if (err)" to "if (err < 0)", where needed.

    rpc_sockname() lost "int buflen" parameter, since its only use was
    to be passed to kernel_getsockname() as &buflen and subsequently
    not used in any way.

    Userspace API is not changed.

    text data bss dec hex filename
    30108430 2633624 873672 33615726 200ef6e vmlinux.before.o
    30108109 2633612 873672 33615393 200ee21 vmlinux.o

    Signed-off-by: Denys Vlasenko
    CC: David S. Miller
    CC: linux-kernel@vger.kernel.org
    CC: netdev@vger.kernel.org
    CC: linux-bluetooth@vger.kernel.org
    CC: linux-decnet-user@lists.sourceforge.net
    CC: linux-wireless@vger.kernel.org
    CC: linux-rdma@vger.kernel.org
    CC: linux-sctp@vger.kernel.org
    CC: linux-nfs@vger.kernel.org
    CC: linux-x25@vger.kernel.org
    Signed-off-by: David S. Miller

    Denys Vlasenko
     

12 Feb, 2018

1 commit

  • This is the mindless scripted replacement of kernel use of POLL*
    variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
    L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
    for f in $L; do sed -i "-es/^\([^\"]*\)\(\\)/\\1E\\2/" $f; done
    done

    with de-mangling cleanups yet to come.

    NOTE! On almost all architectures, the EPOLL* constants have the same
    values as the POLL* constants do. But they keyword here is "almost".
    For various bad reasons they aren't the same, and epoll() doesn't
    actually work quite correctly in some cases due to this on Sparc et al.

    The next patch from Al will sort out the final differences, and we
    should be all done.

    Scripted-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

28 Nov, 2017

1 commit


03 Jul, 2017

1 commit


25 Jun, 2017

1 commit

  • Verify that the caller-provided sockaddr structure is large enough to
    contain the sa_family field, before accessing it in bind() and connect()
    handlers of the AF_IUCV socket. Since neither syscall enforces a minimum
    size of the corresponding memory region, very short sockaddrs (zero or
    one byte long) result in operating on uninitialized memory while
    referencing .sa_family.

    Fixes: 52a82e23b9f2 ("af_iucv: Validate socket address length in iucv_sock_bind()")
    Signed-off-by: Mateusz Jurczyk
    [jwi: removed unneeded null-check for addr]
    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Mateusz Jurczyk