05 Nov, 2020

6 commits


08 Oct, 2020

1 commit

  • * tag 'v5.4.70': (3051 commits)
    Linux 5.4.70
    netfilter: ctnetlink: add a range check for l3/l4 protonum
    ep_create_wakeup_source(): dentry name can change under you...
    ...

    Conflicts:
    arch/arm/mach-imx/pm-imx6.c
    arch/arm64/boot/dts/freescale/imx8mm-evk.dts
    arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
    drivers/crypto/caam/caamalg.c
    drivers/gpu/drm/imx/dw_hdmi-imx.c
    drivers/gpu/drm/imx/imx-ldb.c
    drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c
    drivers/mmc/host/sdhci-esdhc-imx.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/net/ethernet/freescale/enetc/enetc.c
    drivers/net/ethernet/freescale/enetc/enetc_pf.c
    drivers/thermal/imx_thermal.c
    drivers/usb/cdns3/ep0.c
    drivers/xen/swiotlb-xen.c
    sound/soc/fsl/fsl_esai.c
    sound/soc/fsl/fsl_sai.c

    Signed-off-by: Jason Liu

    Jason Liu
     

07 Oct, 2020

5 commits

  • commit 1cc5ef91d2ff94d2bf2de3b3585423e8a1051cb6 upstream.

    The indexes to the nf_nat_l[34]protos arrays come from userspace. So
    check the tuple's family, e.g. l3num, when creating the conntrack in
    order to prevent an OOB memory access during setup. Here is an example
    kernel panic on 4.14.180 when userspace passes in an index greater than
    NFPROTO_NUMPROTO.

    Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
    Modules linked in:...
    Process poc (pid: 5614, stack limit = 0x00000000a3933121)
    CPU: 4 PID: 5614 Comm: poc Tainted: G S W O 4.14.180-g051355490483
    Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150 Google Inc. MSM
    task: 000000002a3dfffe task.stack: 00000000a3933121
    pc : __cfi_check_fail+0x1c/0x24
    lr : __cfi_check_fail+0x1c/0x24
    ...
    Call trace:
    __cfi_check_fail+0x1c/0x24
    name_to_dev_t+0x0/0x468
    nfnetlink_parse_nat_setup+0x234/0x258
    ctnetlink_parse_nat_setup+0x4c/0x228
    ctnetlink_new_conntrack+0x590/0xc40
    nfnetlink_rcv_msg+0x31c/0x4d4
    netlink_rcv_skb+0x100/0x184
    nfnetlink_rcv+0xf4/0x180
    netlink_unicast+0x360/0x770
    netlink_sendmsg+0x5a0/0x6a4
    ___sys_sendmsg+0x314/0x46c
    SyS_sendmsg+0xb4/0x108
    el0_svc_naked+0x34/0x38

    This crash is not happening since 5.4+, however, ctnetlink still
    allows for creating entries with unsupported layer 3 protocol number.

    Fixes: c1d10adb4a521 ("[NETFILTER]: Add ctnetlink port for nf_conntrack")
    Signed-off-by: Will McVicker
    [pablo@netfilter.org: rebased original patch on top of nf.git]
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Will McVicker
     
  • [ Upstream commit 3bd5c7a28a7c3aba07a2d300d43f8e988809e147 ]

    Limit maximum VHT MPDU size by local capability.

    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20200917125031.45009-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Felix Fietkau
     
  • [ Upstream commit 412a84b5714af56f3eb648bba155107b5edddfdf ]

    Radiotap header field 'Channel flags' has '2 GHz spectrum' set to
    'true' for 6GHz packet.
    Change it to 5GHz as there isn't a separate option available for 6GHz.

    Signed-off-by: Aloka Dixit
    Link: https://lore.kernel.org/r/010101747ab7b703-1d7c9851-1594-43bf-81f7-f79ce7a67cc6-000000@us-west-2.amazonses.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Aloka Dixit
     
  • [ Upstream commit df12eb6d6cd920ab2f0e0a43cd6e1c23a05cea91 ]

    Whenever the vsock backend on the host sends a packet through the RX
    queue, it expects an answer on the TX queue. Unfortunately, there is one
    case where the host side will hang waiting for the answer and might
    effectively never recover if no timeout mechanism was implemented.

    This issue happens when the guest side starts binding to the socket,
    which insert a new bound socket into the list of already bound sockets.
    At this time, we expect the guest to also start listening, which will
    trigger the sk_state to move from TCP_CLOSE to TCP_LISTEN. The problem
    occurs if the host side queued a RX packet and triggered an interrupt
    right between the end of the binding process and the beginning of the
    listening process. In this specific case, the function processing the
    packet virtio_transport_recv_pkt() will find a bound socket, which means
    it will hit the switch statement checking for the sk_state, but the
    state won't be changed into TCP_LISTEN yet, which leads the code to pick
    the default statement. This default statement will only free the buffer,
    while it should also respond to the host side, by sending a packet on
    its TX queue.

    In order to simply fix this unfortunate chain of events, it is important
    that in case the default statement is entered, and because at this stage
    we know the host side is waiting for an answer, we must send back a
    packet containing the operation VIRTIO_VSOCK_OP_RST.

    One could say that a proper timeout mechanism on the host side will be
    enough to avoid the backend to hang. But the point of this patch is to
    ensure the normal use case will be provided with proper responsiveness
    when it comes to establishing the connection.

    Signed-off-by: Sebastien Boeuf
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Sebastien Boeuf
     
  • [ Upstream commit 4c7246dc45e2706770d5233f7ce1597a07e069ba ]

    We are going to add 'struct vsock_sock *' parameter to
    virtio_transport_get_ops().

    In some cases, like in the virtio_transport_reset_no_sock(),
    we don't have any socket assigned to the packet received,
    so we can't use the virtio_transport_get_ops().

    In order to allow virtio_transport_reset_no_sock() to use the
    '.send_pkt' callback from the 'vhost_transport' or 'virtio_transport',
    we add the 'struct virtio_transport *' to it and to its caller:
    virtio_transport_recv_pkt().

    We moved the 'vhost_transport' and 'virtio_transport' definition,
    to pass their address to the virtio_transport_recv_pkt().

    Reviewed-by: Stefan Hajnoczi
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Stefano Garzarella
     

01 Oct, 2020

28 commits

  • [ Upstream commit b959ba9f468b1c581f40e92661ad58b093abaa03 ]

    When LIB80211_CRYPT_CCMP is enabled and CRYPTO is disabled, it results in unmet
    direct dependencies config warning. The reason is that LIB80211_CRYPT_CCMP
    selects CRYPTO_AES and CRYPTO_CCM, which are subordinate to CRYPTO. This is
    reproducible with CRYPTO disabled and R8188EU enabled, where R8188EU selects
    LIB80211_CRYPT_CCMP but does not select or depend on CRYPTO.

    Honor the kconfig menu hierarchy to remove kconfig dependency warnings.

    Fixes: a11e2f85481c ("lib80211: use crypto API ccm(aes) transform for CCMP processing")
    Signed-off-by: Necip Fazil Yildiran
    Link: https://lore.kernel.org/r/20200909095452.3080-1-fazilyildiran@gmail.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Necip Fazil Yildiran
     
  • [ Upstream commit 2369e827046920ef0599e6a36b975ac5c0a359c2 ]

    Scenario:
    * Multicast frame send from BLA backbone gateways (multiple nodes
    with their bat0 bridged together, with BLA enabled) sharing the same
    LAN to nodes in the mesh

    Issue:
    * Nodes receive the frame multiple times on bat0 from the mesh,
    once from each foreign BLA backbone gateway which shares the same LAN
    with another

    For multicast frames via batman-adv broadcast packets coming from the
    same BLA backbone but from different backbone gateways duplicates are
    currently detected via a CRC history of previously received packets.

    However this CRC so far was not performed for multicast frames received
    via batman-adv unicast packets. Fixing this by appyling the same check
    for such packets, too.

    Room for improvements in the future: Ideally we would introduce the
    possibility to not only claim a client, but a complete originator, too.
    This would allow us to only send a multicast-in-unicast packet from a BLA
    backbone gateway claiming the node and by that avoid potential redundant
    transmissions in the first place.

    Fixes: 279e89b2281a ("batman-adv: add broadcast duplicate check")
    Signed-off-by: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich
    Signed-off-by: Sasha Levin

    Linus Lüssing
     
  • [ Upstream commit 74c09b7275126da1b642b90c9cdc3ae8b729ad4b ]

    Scenario:
    * Multicast frame send from mesh to a BLA backbone (multiple nodes
    with their bat0 bridged together, with BLA enabled)

    Issue:
    * BLA backbone nodes receive the frame multiple times on bat0,
    once from mesh->bat0 and once from each backbone_gw from LAN

    For unicast, a node will send only to the best backbone gateway
    according to the TQ. However for multicast we currently cannot determine
    if multiple destination nodes share the same backbone if they don't share
    the same backbone with us. So we need to keep sending the unicasts to
    all backbone gateways and let the backbone gateways decide which one
    will forward the frame. We can use the CLAIM mechanism to make this
    decision.

    One catch: The batman-adv gateway feature for DHCP packets potentially
    sends multicast packets in the same batman-adv unicast header as the
    multicast optimizations code. And we are not allowed to drop those even
    if we did not claim the source address of the sender, as for such
    packets there is only this one multicast-in-unicast packet.

    How can we distinguish the two cases?

    The gateway feature uses a batman-adv unicast 4 address header. While
    the multicast-to-unicasts feature uses a simple, 3 address batman-adv
    unicast header. So let's use this to distinguish.

    Fixes: fe2da6ff27c7 ("batman-adv: check incoming packet type for bla")
    Signed-off-by: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich
    Signed-off-by: Sasha Levin

    Linus Lüssing
     
  • [ Upstream commit 3236d215ad38a3f5372e65cd1e0a52cf93d3c6a2 ]

    Scenario:
    * Multicast frame send from a BLA backbone (multiple nodes with
    their bat0 bridged together, with BLA enabled)

    Issue:
    * BLA backbone nodes receive the frame multiple times on bat0

    For multicast frames received via batman-adv broadcast packets the
    originator of the broadcast packet is checked before decapsulating and
    forwarding the frame to bat0 (batadv_bla_is_backbone_gw()->
    batadv_recv_bcast_packet()). If it came from a node which shares the
    same BLA backbone with us then it is not forwarded to bat0 to avoid a
    loop.

    When sending a multicast frame in a non-4-address batman-adv unicast
    packet we are currently missing this check - and cannot do so because
    the batman-adv unicast packet has no originator address field.

    However, we can simply fix this on the sender side by only sending the
    multicast frame via unicasts to interested nodes which do not share the
    same BLA backbone with us. This also nicely avoids some unnecessary
    transmissions on mesh side.

    Note that no infinite loop was observed, probably because of dropping
    via batadv_interface_tx()->batadv_bla_tx(). However the duplicates still
    utterly confuse switches/bridges, ICMPv6 duplicate address detection and
    neighbor discovery and therefore leads to long delays before being able
    to establish TCP connections, for instance. And it also leads to the Linux
    bridge printing messages like:
    "br-lan: received packet on eth1 with own address as source address ..."

    Fixes: 2d3f6ccc4ea5 ("batman-adv: Modified forwarding behaviour for multicast packets")
    Signed-off-by: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich
    Signed-off-by: Sasha Levin

    Linus Lüssing
     
  • [ Upstream commit 4bba9dab86b6ac15ca560ef1f2b5aa4529cbf784 ]

    The fix for receiving (internally generated) bla packets outside the
    interrupt context introduced the usage of in_interrupt(). But this
    functionality is only defined in linux/preempt.h which was not included
    with the same patch.

    Fixes: 279e89b2281a ("batman-adv: bla: use netif_rx_ni when not in interrupt context")
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich
    Signed-off-by: Sasha Levin

    Sven Eckelmann
     
  • [ Upstream commit e6a18d36118bea3bf497c9df4d9988b6df120689 ]

    Bryce reported that he saw the following with:

    0: r6 = r1
    1: r1 = 12
    2: r0 = *(u16 *)skb[r1]

    The xlated sequence was incorrectly clobbering r2 with pointer
    value of r6 ...

    0: (bf) r6 = r1
    1: (b7) r1 = 12
    2: (bf) r1 = r6
    3: (bf) r2 = r1
    4: (85) call bpf_skb_load_helper_16_no_cache#7692160

    ... and hence call to the load helper never succeeded given the
    offset was too high. Fix it by reordering the load of r6 to r1.

    Other than that the insn has similar calling convention than BPF
    helpers, that is, r0 - r5 are scratch regs, so nothing else
    affected after the insn.

    Fixes: e0cea7ce988c ("bpf: implement ld_abs/ld_ind in native bpf")
    Reported-by: Bryce Kahle
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/cace836e4d07bb63b1a53e49c5dfb238a040c298.1599512096.git.daniel@iogearbox.net
    Signed-off-by: Sasha Levin

    Daniel Borkmann
     
  • [ Upstream commit 0ff4628f4c6c1ab87eef9f16b25355cadc426d64 ]

    syzbot reported a bug in ieee802154_tx() [1]

    A similar issue in ieee802154_xmit_worker() is also fixed in this patch.

    [1]
    BUG: KASAN: use-after-free in ieee802154_tx+0x3d2/0x480 net/mac802154/tx.c:88
    Read of size 4 at addr ffff8880251a8c70 by task syz-executor.3/928

    CPU: 0 PID: 928 Comm: syz-executor.3 Not tainted 5.9.0-rc3-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x198/0x1fd lib/dump_stack.c:118
    print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
    __kasan_report mm/kasan/report.c:513 [inline]
    kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
    ieee802154_tx+0x3d2/0x480 net/mac802154/tx.c:88
    ieee802154_subif_start_xmit+0xbe/0xe4 net/mac802154/tx.c:130
    __netdev_start_xmit include/linux/netdevice.h:4634 [inline]
    netdev_start_xmit include/linux/netdevice.h:4648 [inline]
    dev_direct_xmit+0x4e9/0x6e0 net/core/dev.c:4203
    packet_snd net/packet/af_packet.c:2989 [inline]
    packet_sendmsg+0x2413/0x5290 net/packet/af_packet.c:3014
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg+0xcf/0x120 net/socket.c:671
    ____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
    ___sys_sendmsg+0xf3/0x170 net/socket.c:2407
    __sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
    do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x45d5b9
    Code: 5d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 3d 01 f0 ff ff 0f 83 2b b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00
    RSP: 002b:00007fc98e749c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 000000000002ccc0 RCX: 000000000045d5b9
    RDX: 0000000000000000 RSI: 0000000020007780 RDI: 000000000000000b
    RBP: 000000000118d020 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118cfec
    R13: 00007fff690c720f R14: 00007fc98e74a9c0 R15: 000000000118cfec

    Allocated by task 928:
    kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
    kasan_set_track mm/kasan/common.c:56 [inline]
    __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
    slab_post_alloc_hook mm/slab.h:518 [inline]
    slab_alloc_node mm/slab.c:3254 [inline]
    kmem_cache_alloc_node+0x136/0x3e0 mm/slab.c:3574
    __alloc_skb+0x71/0x550 net/core/skbuff.c:198
    alloc_skb include/linux/skbuff.h:1094 [inline]
    alloc_skb_with_frags+0x92/0x570 net/core/skbuff.c:5771
    sock_alloc_send_pskb+0x72a/0x880 net/core/sock.c:2348
    packet_alloc_skb net/packet/af_packet.c:2837 [inline]
    packet_snd net/packet/af_packet.c:2932 [inline]
    packet_sendmsg+0x19fb/0x5290 net/packet/af_packet.c:3014
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg+0xcf/0x120 net/socket.c:671
    ____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
    ___sys_sendmsg+0xf3/0x170 net/socket.c:2407
    __sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
    do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Freed by task 928:
    kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
    kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
    kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
    __kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
    __cache_free mm/slab.c:3418 [inline]
    kmem_cache_free.part.0+0x74/0x1e0 mm/slab.c:3693
    kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:622
    __kfree_skb net/core/skbuff.c:679 [inline]
    consume_skb net/core/skbuff.c:838 [inline]
    consume_skb+0xcf/0x160 net/core/skbuff.c:832
    __dev_kfree_skb_any+0x9c/0xc0 net/core/dev.c:3107
    fakelb_hw_xmit+0x20e/0x2a0 drivers/net/ieee802154/fakelb.c:81
    drv_xmit_async net/mac802154/driver-ops.h:16 [inline]
    ieee802154_tx+0x282/0x480 net/mac802154/tx.c:81
    ieee802154_subif_start_xmit+0xbe/0xe4 net/mac802154/tx.c:130
    __netdev_start_xmit include/linux/netdevice.h:4634 [inline]
    netdev_start_xmit include/linux/netdevice.h:4648 [inline]
    dev_direct_xmit+0x4e9/0x6e0 net/core/dev.c:4203
    packet_snd net/packet/af_packet.c:2989 [inline]
    packet_sendmsg+0x2413/0x5290 net/packet/af_packet.c:3014
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg+0xcf/0x120 net/socket.c:671
    ____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
    ___sys_sendmsg+0xf3/0x170 net/socket.c:2407
    __sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
    do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    The buggy address belongs to the object at ffff8880251a8c00
    which belongs to the cache skbuff_head_cache of size 224
    The buggy address is located 112 bytes inside of
    224-byte region [ffff8880251a8c00, ffff8880251a8ce0)
    The buggy address belongs to the page:
    page:0000000062b6a4f1 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x251a8
    flags: 0xfffe0000000200(slab)
    raw: 00fffe0000000200 ffffea0000435c88 ffffea00028b6c08 ffff8880a9055d00
    raw: 0000000000000000 ffff8880251a80c0 000000010000000c 0000000000000000
    page dumped because: kasan: bad access detected

    Memory state around the buggy address:
    ffff8880251a8b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ffff8880251a8b80: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
    >ffff8880251a8c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ^
    ffff8880251a8c80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
    ffff8880251a8d00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb

    Fixes: 409c3b0c5f03 ("mac802154: tx: move stats tx increment")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Cc: Alexander Aring
    Cc: Stefan Schmidt
    Cc: linux-wpan@vger.kernel.org
    Link: https://lore.kernel.org/r/20200908104025.4009085-1-edumazet@google.com
    Signed-off-by: Stefan Schmidt
    Signed-off-by: Sasha Levin

    Eric Dumazet
     
  • [ Upstream commit 526e81b990e53e31ba40ba304a2285ffd098721f ]

    The openvswitch module fails initialization when used in a kernel
    without IPv6 enabled. nf_conncount_init() fails because the ct code
    unconditionally tries to initialize the netns IPv6 related bit,
    regardless of the build option. The change below ignores the IPv6
    part if not enabled.

    Note that the corresponding _put() function already has this IPv6
    configuration check.

    Fixes: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
    Signed-off-by: Eelco Chaudron
    Reviewed-by: Simon Horman
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin

    Eelco Chaudron
     
  • [ Upstream commit 7dda5b3384121181c4e79f6eaeac2b94c0622c8d ]

    The unicast packet rerouting code makes several assumptions. For
    instance it assumes that there is always exactly one destination in the
    TT. This breaks for multicast frames in a unicast packets in several ways:

    For one thing if there is actually no TT entry and the destination node
    was selected due to the multicast tvlv flags it announced. Then an
    intermediate node will wrongly drop the packet.

    For another thing if there is a TT entry but the TTVN of this entry is
    newer than the originally addressed destination node: Then the
    intermediate node will wrongly redirect the packet, leading to
    duplicated multicast packets at a multicast listener and missing
    packets at other multicast listeners or multicast routers.

    Fixing this by not applying the unicast packet rerouting to batman-adv
    unicast packets with a multicast payload. We are not able to detect a
    roaming multicast listener at the moment and will just continue to send
    the multicast frame to both the new and old destination for a while in
    case of such a roaming multicast listener.

    Fixes: a73105b8d4c7 ("batman-adv: improved client announcement mechanism")
    Signed-off-by: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich
    Signed-off-by: Sasha Levin

    Linus Lüssing
     
  • [ Upstream commit 097930e85f90f252c44dc0d084598265dd44ca48 ]

    It seems that due to a copy & paste error the void pointer
    in batadv_choose_backbone_gw() is cast to the wrong type.

    Fixing this by using "struct batadv_bla_backbone_gw" instead of "struct
    batadv_bla_claim" which better matches the caller's side.

    For now it seems that we were lucky because the two structs both have
    their orig/vid and addr/vid in the beginning. However I stumbled over
    this issue when I was trying to add some debug variables in front of
    "orig" in batadv_backbone_gw, which caused hash lookups to fail.

    Fixes: 07568d0369f9 ("batman-adv: don't rely on positions in struct for hashing")
    Signed-off-by: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Sasha Levin

    Linus Lüssing
     
  • [ Upstream commit 659d4587fe7233bfdff303744b20d6f41ad04362 ]

    Compile the kernel for arm 32 platform, the build warning found.
    To fix that, should use div_u64() for divisions.
    | net/openvswitch/meter.c:396: undefined reference to `__udivdi3'

    [add more commit msg, change reported tag, and use div_u64 instead
    of do_div by Tonghao]

    Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
    Reported-by: kbuild test robot
    Signed-off-by: Tonghao Zhang
    Tested-by: Tonghao Zhang
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Tonghao Zhang
     
  • [ Upstream commit 5af7fef39d7952c0f5551afa7b821ee7b6c9dd3d ]

    When using 802.1X over mesh networks, at first an ordinary
    mesh peering is established, then the 802.1X EAPOL dialog
    happens, afterwards an authenticated mesh peering exchange
    (AMPE) happens, finally the peering is complete and we can
    set the STA authorized flag.

    As 802.1X is an intermediate step here and key material is
    not yet exchanged for stations we have to skip mesh path lookup
    for these EAPOL frames. Otherwise the already configure mesh
    group encryption key would be used to send a mesh path request
    which no one can decipher, because we didn't already establish
    key material on both peers, like with SAE and directly using AMPE.

    Signed-off-by: Markus Theil
    Link: https://lore.kernel.org/r/20200617082637.22670-2-markus.theil@tu-ilmenau.de
    [remove pointless braces, remove unnecessary local variable,
    the list can only process one such frame (or its fragments)]
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Markus Theil
     
  • [ Upstream commit ea740bd5f58e2912e74f401fd01a9d6aa985ca05 ]

    Way back when I was writing the RPC/RDMA server-side backchannel
    code, I misread the TCP backchannel reply handler logic. When
    svc_tcp_recvfrom() successfully receives a backchannel reply, it
    does not return -EAGAIN. It sets XPT_DATA and returns zero.

    Update svc_rdma_recvfrom() to return zero. Here, XPT_DATA doesn't
    need to be set again: it is set whenever a new message is received,
    behind a spin lock in a single threaded context.

    Also, if handling the cb reply is not successful, the message is
    simply dropped. There's no special message framing to deal with as
    there is in the TCP case.

    Now that the handle_bc_reply() return value is ignored, I've removed
    the dprintk call sites in the error exit of handle_bc_reply() in
    favor of trace points in other areas that already report the error
    cases.

    Signed-off-by: Chuck Lever
    Signed-off-by: Sasha Levin

    Chuck Lever
     
  • [ Upstream commit 0771d7df819284d46cf5cfb57698621b503ec17f ]

    Upon receipt of a service subscription request from user via a topology
    connection, one 'sub' object will be allocated in kernel, so it will be
    able to send an event of the service if any to the user correspondingly
    then. Also, in case of any failure, the connection will be shutdown and
    all the pertaining 'sub' objects will be freed.

    However, there is a race condition as follows resulting in memory leak:

    receive-work connection send-work
    | | |
    sub-1 | orphan | |

    That is, the 'receive-work' may get the last subscription request while
    the 'send-work' is shutting down the connection due to peer close.

    We had a 'lock' on the connection, so the two actions cannot be carried
    out simultaneously. If the last subscription is allocated e.g. 'sub-n',
    before the 'send-work' closes the connection, there will be no issue at
    all, the 'sub' objects will be freed. In contrast the last subscription
    will become orphan since the connection was closed, and we released all
    references.

    This commit fixes the issue by simply adding one test if the connection
    remains in 'connected' state right after we obtain the connection lock,
    then a subscription object can be created as usual, otherwise we ignore
    it.

    Acked-by: Ying Xue
    Acked-by: Jon Maloy
    Reported-by: Thang Ngo
    Signed-off-by: Tuong Lien
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Tuong Lien
     
  • [ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ]

    After sending Inquiry Cancel command to the controller, it is possible
    that Inquiry Complete event comes before Inquiry Cancel command complete
    event. In this case the Inquiry Cancel command will have status of
    Command Disallowed since there is no Inquiry session to be cancelled.
    This case should not be treated as error, otherwise we can reach an
    inconsistent state.

    Example of a btmon trace when this happened:

    < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0
    > HCI Event: Inquiry Complete (0x01) plen 1
    Status: Success (0x00)
    > HCI Event: Command Complete (0x0e) plen 4
    Inquiry Cancel (0x01|0x0002) ncmd 1
    Status: Command Disallowed (0x0c)

    Signed-off-by: Sonny Sasaka
    Signed-off-by: Marcel Holtmann
    Signed-off-by: Sasha Levin

    Sonny Sasaka
     
  • [ Upstream commit 8d9f73c0ad2f20e9fed5380de0a3097825859d03 ]

    In lec_arp_clear_vccs() only entry->vcc is freed, but vcc
    could be installed on entry->recv_vcc too in lec_vcc_added().

    This fixes the following memory leak:

    unreferenced object 0xffff8880d9266b90 (size 16):
    comm "atm2", pid 425, jiffies 4294907980 (age 23.488s)
    hex dump (first 16 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 6b 6b 6b a5 ............kkk.
    backtrace:
    [] kmem_cache_alloc_trace+0x10e/0x151
    [] lane_ioctl+0x4b3/0x569
    [] do_vcc_ioctl+0x1ea/0x236
    [] svc_ioctl+0x17d/0x198
    [] sock_do_ioctl+0x47/0x12f
    [] sock_ioctl+0x2f9/0x322
    [] vfs_ioctl+0x1e/0x2b
    [] ksys_ioctl+0x61/0x80
    [] __x64_sys_ioctl+0x16/0x19
    [] do_syscall_64+0x57/0x65
    [] entry_SYSCALL_64_after_hwframe+0x49/0xb3

    Cc: Gengming Liu
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Cong Wang
     
  • [ Upstream commit bea0c5c942d3b4e9fb6ed45f6a7de74c6b112437 ]

    Devlink health core conditions the reporter's recovery with the
    expiration of the grace period. This is not relevant for the first
    recovery. Explicitly demand that the grace period will only apply to
    recoveries other than the first.

    Fixes: c8e1da0bf923 ("devlink: Add health report functionality")
    Signed-off-by: Aya Levin
    Reviewed-by: Moshe Shemesh
    Reviewed-by: Jiri Pirko
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Aya Levin
     
  • [ Upstream commit e57358873bb5d6caa882b9684f59140912b37dde ]

    When setting the meter rate to 4+Gbps, there is an
    overflow, the meters don't work as expected.

    Cc: Pravin B Shelar
    Cc: Andy Zhou
    Signed-off-by: Tonghao Zhang
    Acked-by: Pravin B Shelar
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Tonghao Zhang
     
  • [ Upstream commit 1fab7dc477241c12f977955aa6baea7938b6f08d ]

    Move the test for whether a task is already queued to prevent
    corruption of the timer list in __rpc_sleep_on_priority_timeout().

    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit 0a6a9515fe390976cd762c52d8d4f446d7a14285 ]

    It is safe to traverse &net->nft.tables with &net->nft.commit_mutex
    held using list_for_each_entry_rcu(). Silence the PROVE_RCU_LIST false
    positive,

    WARNING: suspicious RCU usage
    net/netfilter/nf_tables_api.c:523 RCU-list traversed in non-reader section!!

    other info that might help us debug this:

    rcu_scheduler_active = 2, debug_locks = 1
    1 lock held by iptables/1384:
    #0: ffffffff9745c4a8 (&net->nft.commit_mutex){+.+.}, at: nf_tables_valid_genid+0x25/0x60 [nf_tables]

    Call Trace:
    dump_stack+0xa1/0xea
    lockdep_rcu_suspicious+0x103/0x10d
    nft_table_lookup.part.0+0x116/0x120 [nf_tables]
    nf_tables_newtable+0x12c/0x7d0 [nf_tables]
    nfnetlink_rcv_batch+0x559/0x1190 [nfnetlink]
    nfnetlink_rcv+0x1da/0x210 [nfnetlink]
    netlink_unicast+0x306/0x460
    netlink_sendmsg+0x44b/0x770
    ____sys_sendmsg+0x46b/0x4a0
    ___sys_sendmsg+0x138/0x1a0
    __sys_sendmsg+0xb6/0x130
    __x64_sys_sendmsg+0x48/0x50
    do_syscall_64+0x69/0xf4
    entry_SYSCALL_64_after_hwframe+0x49/0xb3

    Signed-off-by: Qian Cai
    Acked-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin

    Qian Cai
     
  • [ Upstream commit 1a33d8a284b1e85e03b8c7b1ea8fb985fccd1d71 ]

    Kernel memory leak detected:

    unreferenced object 0xffff888849cdf480 (size 8):
    comm "kworker/u8:3", pid 2086, jiffies 4297898756 (age 4269.856s)
    hex dump (first 8 bytes):
    30 00 cd 49 88 88 ff ff 0..I....
    backtrace:
    [] __kmalloc_track_caller+0x137/0x183
    [] kstrdup+0x2b/0x43
    [] xprt_rdma_format_addresses+0x114/0x17d [rpcrdma]
    [] xprt_setup_rdma_bc+0xc0/0x10c [rpcrdma]
    [] xprt_create_transport+0x3f/0x1a0 [sunrpc]
    [] rpc_create+0x118/0x1cd [sunrpc]
    [] setup_callback_client+0x1a5/0x27d [nfsd]
    [] nfsd4_process_cb_update.isra.7+0x16c/0x1ac [nfsd]
    [] nfsd4_run_cb_work+0x4c/0xbd [nfsd]
    [] process_one_work+0x1b2/0x2fe
    [] worker_thread+0x1a6/0x25a
    [] kthread+0xf6/0xfb
    [] ret_from_fork+0x3a/0x50

    Introduce a call to xprt_rdma_free_addresses() similar to the way
    that the TCP backchannel releases a transport's peer address
    strings.

    Fixes: 5d252f90a800 ("svcrdma: Add class for RDMA backwards direction transport")
    Signed-off-by: Chuck Lever
    Signed-off-by: Sasha Levin

    Chuck Lever
     
  • [ Upstream commit b25b60d7bfb02a74bc3c2d998e09aab159df8059 ]

    'maxlen' is the total size of the destination buffer. There is only one
    caller and this value is 256.

    When we compute the size already used and what we would like to add in
    the buffer, the trailling NULL character is not taken into account.
    However, this trailling character will be added by the 'strcat' once we
    have checked that we have enough place.

    So, there is a off-by-one issue and 1 byte of the stack could be
    erroneously overwridden.

    Take into account the trailling NULL, when checking if there is enough
    place in the destination buffer.

    While at it, also replace a 'sprintf' by a safer 'snprintf', check for
    output truncation and avoid a superfluous 'strlen'.

    Fixes: dc9a16e49dbba ("svc: Add /proc/sys/sunrpc/transport files")
    Signed-off-by: Christophe JAILLET
    [ cel: very minor fix to documenting comment
    Signed-off-by: Chuck Lever
    Signed-off-by: Sasha Levin

    Christophe JAILLET
     
  • [ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ]

    According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5,
    the incoming L2CAP_ConfigReq should be handled during
    OPEN state.

    The section below shows the btmon trace when running
    L2CAP/COS/CFD/BV-12-C before and after this change.

    === Before ===
    ...
    > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22
    L2CAP: Connection Request (0x02) ident 2 len 4
    PSM: 1 (0x0001)
    Source CID: 65
    < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23
    L2CAP: Connection Response (0x03) ident 2 len 8
    Destination CID: 64
    Source CID: 65
    Result: Connection successful (0x0000)
    Status: No further information available (0x0000)
    < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24
    L2CAP: Configure Request (0x04) ident 2 len 4
    Destination CID: 65
    Flags: 0x0000
    > HCI Event: Number of Completed Packets (0x13) plen 5 #25
    Num handles: 1
    Handle: 256
    Count: 1
    > HCI Event: Number of Completed Packets (0x13) plen 5 #26
    Num handles: 1
    Handle: 256
    Count: 1
    > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27
    L2CAP: Configure Request (0x04) ident 3 len 8
    Destination CID: 64
    Flags: 0x0000
    Option: Unknown (0x10) [hint]
    01 00 ..
    < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28
    L2CAP: Configure Response (0x05) ident 3 len 10
    Source CID: 65
    Flags: 0x0000
    Result: Success (0x0000)
    Option: Maximum Transmission Unit (0x01) [mandatory]
    MTU: 672
    > HCI Event: Number of Completed Packets (0x13) plen 5 #29
    Num handles: 1
    Handle: 256
    Count: 1
    > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30
    L2CAP: Configure Response (0x05) ident 2 len 6
    Source CID: 64
    Flags: 0x0000
    Result: Success (0x0000)
    > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31
    L2CAP: Configure Request (0x04) ident 3 len 12
    Destination CID: 64
    Flags: 0x0000
    Option: Unknown (0x10) [hint]
    01 00 91 02 11 11 ......
    < ACL Data TX: Handle 256 flags 0x00 dlen 14 #32
    L2CAP: Command Reject (0x01) ident 3 len 6
    Reason: Invalid CID in request (0x0002)
    Destination CID: 64
    Source CID: 65
    > HCI Event: Number of Completed Packets (0x13) plen 5 #33
    Num handles: 1
    Handle: 256
    Count: 1
    ...
    === After ===
    ...
    > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22
    L2CAP: Connection Request (0x02) ident 2 len 4
    PSM: 1 (0x0001)
    Source CID: 65
    < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23
    L2CAP: Connection Response (0x03) ident 2 len 8
    Destination CID: 64
    Source CID: 65
    Result: Connection successful (0x0000)
    Status: No further information available (0x0000)
    < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24
    L2CAP: Configure Request (0x04) ident 2 len 4
    Destination CID: 65
    Flags: 0x0000
    > HCI Event: Number of Completed Packets (0x13) plen 5 #25
    Num handles: 1
    Handle: 256
    Count: 1
    > HCI Event: Number of Completed Packets (0x13) plen 5 #26
    Num handles: 1
    Handle: 256
    Count: 1
    > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27
    L2CAP: Configure Request (0x04) ident 3 len 8
    Destination CID: 64
    Flags: 0x0000
    Option: Unknown (0x10) [hint]
    01 00 ..
    < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28
    L2CAP: Configure Response (0x05) ident 3 len 10
    Source CID: 65
    Flags: 0x0000
    Result: Success (0x0000)
    Option: Maximum Transmission Unit (0x01) [mandatory]
    MTU: 672
    > HCI Event: Number of Completed Packets (0x13) plen 5 #29
    Num handles: 1
    Handle: 256
    Count: 1
    > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30
    L2CAP: Configure Response (0x05) ident 2 len 6
    Source CID: 64
    Flags: 0x0000
    Result: Success (0x0000)
    > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31
    L2CAP: Configure Request (0x04) ident 3 len 12
    Destination CID: 64
    Flags: 0x0000
    Option: Unknown (0x10) [hint]
    01 00 91 02 11 11 .....
    < ACL Data TX: Handle 256 flags 0x00 dlen 18 #32
    L2CAP: Configure Response (0x05) ident 3 len 10
    Source CID: 65
    Flags: 0x0000
    Result: Success (0x0000)
    Option: Maximum Transmission Unit (0x01) [mandatory]
    MTU: 672
    < ACL Data TX: Handle 256 flags 0x00 dlen 12 #33
    L2CAP: Configure Request (0x04) ident 3 len 4
    Destination CID: 65
    Flags: 0x0000
    > HCI Event: Number of Completed Packets (0x13) plen 5 #34
    Num handles: 1
    Handle: 256
    Count: 1
    > HCI Event: Number of Completed Packets (0x13) plen 5 #35
    Num handles: 1
    Handle: 256
    Count: 1
    ...

    Signed-off-by: Howard Chung
    Signed-off-by: Marcel Holtmann
    Signed-off-by: Sasha Levin

    Howard Chung
     
  • [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ]

    Some controllers have been observed to send zero'd events under some
    conditions. This change guards against this condition as well as adding
    a trace to facilitate diagnosability of this condition.

    Signed-off-by: Alain Michaud
    Signed-off-by: Marcel Holtmann
    Signed-off-by: Sasha Levin

    Alain Michaud
     
  • [ Upstream commit 86b18aaa2b5b5bb48e609cd591b3d2d0fdbe0442 ]

    sk_buff.qlen can be accessed concurrently as noticed by KCSAN,

    BUG: KCSAN: data-race in __skb_try_recv_from_queue / unix_dgram_sendmsg

    read to 0xffff8a1b1d8a81c0 of 4 bytes by task 5371 on cpu 96:
    unix_dgram_sendmsg+0x9a9/0xb70 include/linux/skbuff.h:1821
    net/unix/af_unix.c:1761
    ____sys_sendmsg+0x33e/0x370
    ___sys_sendmsg+0xa6/0xf0
    __sys_sendmsg+0x69/0xf0
    __x64_sys_sendmsg+0x51/0x70
    do_syscall_64+0x91/0xb47
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    write to 0xffff8a1b1d8a81c0 of 4 bytes by task 1 on cpu 99:
    __skb_try_recv_from_queue+0x327/0x410 include/linux/skbuff.h:2029
    __skb_try_recv_datagram+0xbe/0x220
    unix_dgram_recvmsg+0xee/0x850
    ____sys_recvmsg+0x1fb/0x210
    ___sys_recvmsg+0xa2/0xf0
    __sys_recvmsg+0x66/0xf0
    __x64_sys_recvmsg+0x51/0x70
    do_syscall_64+0x91/0xb47
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    Since only the read is operating as lockless, it could introduce a logic
    bug in unix_recvq_full() due to the load tearing. Fix it by adding
    a lockless variant of skb_queue_len() and unix_recvq_full() where
    READ_ONCE() is on the read while WRITE_ONCE() is on the write similar to
    the commit d7d16a89350a ("net: add skb_queue_empty_lockless()").

    Signed-off-by: Qian Cai
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Qian Cai
     
  • [ Upstream commit 2a154903cec20fb64ff4d7d617ca53c16f8fd53a ]

    Prefetch channel before killing sock in order to fix UAF like

    BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212
    Read of size 8 at addr ffff8880944904a0 by task syz-fuzzer/9751

    Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com
    Fixes: 6c08fc896b60 ("Bluetooth: Fix refcount use-after-free issue")
    Cc: Manish Mandlik
    Signed-off-by: Hillf Danton
    Signed-off-by: Marcel Holtmann
    Signed-off-by: Sasha Levin

    Hillf Danton
     
  • [ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ]

    There is no lock preventing both l2cap_sock_release() and
    chan->ops->close() from running at the same time.

    If we consider Thread A running l2cap_chan_timeout() and Thread B running
    l2cap_sock_release(), expected behavior is:
    A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb()
    A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill()
    B::l2cap_sock_release()->sock_orphan()
    B::l2cap_sock_release()->l2cap_sock_kill()

    where,
    sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks
    socket as SOCK_ZAPPED.

    In l2cap_sock_kill(), there is an "if-statement" that checks if both
    sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL
    and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is
    satisfied.

    In the race condition, following occurs:
    A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb()
    B::l2cap_sock_release()->sock_orphan()
    B::l2cap_sock_release()->l2cap_sock_kill()
    A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill()

    In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and
    A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug.

    Similar condition occurs at other places where teardown/sock_kill is
    happening:
    l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb()
    l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill()

    l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb()
    l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill()

    l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb()
    l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill()

    l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb()
    l2cap_sock_cleanup_listen()->l2cap_sock_kill()

    Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on
    l2cap channel to ensure that the socket is killed only after marked as
    zapped and orphan.

    Signed-off-by: Manish Mandlik
    Signed-off-by: Marcel Holtmann
    Signed-off-by: Sasha Levin

    Manish Mandlik
     
  • [ Upstream commit f643ee295c1c63bc117fb052d4da681354d6f732 ]

    The original patch bringed in the "SCTP ACK tracking trace event"
    feature was committed at Dec.20, 2017, it replaced jprobe usage
    with trace events, and bringed in two trace events, one is
    TRACE_EVENT(sctp_probe), another one is TRACE_EVENT(sctp_probe_path).
    The original patch intended to trigger the trace_sctp_probe_path in
    TRACE_EVENT(sctp_probe) as below code,

    +TRACE_EVENT(sctp_probe,
    +
    + TP_PROTO(const struct sctp_endpoint *ep,
    + const struct sctp_association *asoc,
    + struct sctp_chunk *chunk),
    +
    + TP_ARGS(ep, asoc, chunk),
    +
    + TP_STRUCT__entry(
    + __field(__u64, asoc)
    + __field(__u32, mark)
    + __field(__u16, bind_port)
    + __field(__u16, peer_port)
    + __field(__u32, pathmtu)
    + __field(__u32, rwnd)
    + __field(__u16, unack_data)
    + ),
    +
    + TP_fast_assign(
    + struct sk_buff *skb = chunk->skb;
    +
    + __entry->asoc = (unsigned long)asoc;
    + __entry->mark = skb->mark;
    + __entry->bind_port = ep->base.bind_addr.port;
    + __entry->peer_port = asoc->peer.port;
    + __entry->pathmtu = asoc->pathmtu;
    + __entry->rwnd = asoc->peer.rwnd;
    + __entry->unack_data = asoc->unack_data;
    +
    + if (trace_sctp_probe_path_enabled()) {
    + struct sctp_transport *sp;
    +
    + list_for_each_entry(sp, &asoc->peer.transport_addr_list,
    + transports) {
    + trace_sctp_probe_path(sp, asoc);
    + }
    + }
    + ),

    But I found it did not work when I did testing, and trace_sctp_probe_path
    had no output, I finally found that there is trace buffer lock
    operation(trace_event_buffer_reserve) in include/trace/trace_events.h:

    static notrace void \
    trace_event_raw_event_##call(void *__data, proto) \
    { \
    struct trace_event_file *trace_file = __data; \
    struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
    struct trace_event_buffer fbuffer; \
    struct trace_event_raw_##call *entry; \
    int __data_size; \
    \
    if (trace_trigger_soft_disabled(trace_file)) \
    return; \
    \
    __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
    \
    entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
    sizeof(*entry) + __data_size); \
    \
    if (!entry) \
    return; \
    \
    tstruct \
    \
    { assign; } \
    \
    trace_event_buffer_commit(&fbuffer); \
    }

    The reason caused no output of trace_sctp_probe_path is that
    trace_sctp_probe_path written in TP_fast_assign part of
    TRACE_EVENT(sctp_probe), and it will be placed( { assign; } ) after the
    trace_event_buffer_reserve() when compiler expands Macro,

    entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
    sizeof(*entry) + __data_size); \
    \
    if (!entry) \
    return; \
    \
    tstruct \
    \
    { assign; } \

    so trace_sctp_probe_path finally can not acquire trace_event_buffer
    and return no output, that is to say the nest of tracepoint entry function
    is not allowed. The function call flow is:

    trace_sctp_probe()
    -> trace_event_raw_event_sctp_probe()
    -> lock buffer
    -> trace_sctp_probe_path()
    -> trace_event_raw_event_sctp_probe_path() --nested
    -> buffer has been locked and return no output.

    This patch is to remove trace_sctp_probe_path from the TP_fast_assign
    part of TRACE_EVENT(sctp_probe) to avoid the nest of entry function,
    and trigger sctp_probe_path_trace in sctp_outq_sack.

    After this patch, you can enable both events individually,
    # cd /sys/kernel/debug/tracing
    # echo 1 > events/sctp/sctp_probe/enable
    # echo 1 > events/sctp/sctp_probe_path/enable

    Or, you can enable all the events under sctp.

    # echo 1 > events/sctp/enable

    Signed-off-by: Kevin Kou
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Kevin Kou