04 Feb, 2021

1 commit

  • syzbot found WARNING in qrtr_tun_write_iter [1] when write_iter length
    exceeds KMALLOC_MAX_SIZE causing order >= MAX_ORDER condition.

    Additionally, there is no check for 0 length write.

    [1]
    WARNING: mm/page_alloc.c:5011
    [..]
    Call Trace:
    alloc_pages_current+0x18c/0x2a0 mm/mempolicy.c:2267
    alloc_pages include/linux/gfp.h:547 [inline]
    kmalloc_order+0x2e/0xb0 mm/slab_common.c:837
    kmalloc_order_trace+0x14/0x120 mm/slab_common.c:853
    kmalloc include/linux/slab.h:557 [inline]
    kzalloc include/linux/slab.h:682 [inline]
    qrtr_tun_write_iter+0x8a/0x180 net/qrtr/tun.c:83
    call_write_iter include/linux/fs.h:1901 [inline]

    Reported-by: syzbot+c2a7e5c5211605a90865@syzkaller.appspotmail.com
    Signed-off-by: Sabyrzhan Tasbolatov
    Link: https://lore.kernel.org/r/20210202092059.1361381-1-snovitoll@gmail.com
    Signed-off-by: Jakub Kicinski

    Sabyrzhan Tasbolatov
     

06 Jan, 2021

1 commit

  • A null-ptr-deref bug is reported by Hulk Robot like this:
    --------------
    KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
    Call Trace:
    qrtr_ns_remove+0x22/0x40 [ns]
    qrtr_proto_fini+0xa/0x31 [qrtr]
    __x64_sys_delete_module+0x337/0x4e0
    do_syscall_64+0x34/0x80
    entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x468ded
    --------------

    When qrtr_ns_init fails in qrtr_proto_init, qrtr_ns_remove which would
    be called later on would raise a null-ptr-deref because qrtr_ns.workqueue
    has been destroyed.

    Fix it by making qrtr_ns_init have a return value and adding a check in
    qrtr_proto_init.

    Reported-by: Hulk Robot
    Signed-off-by: Qinglang Miao
    Signed-off-by: David S. Miller

    Qinglang Miao
     

05 Dec, 2020

1 commit

  • …ux/kernel/git/kvalo/wireless-drivers-next

    Kalle Valo says:

    ====================
    wireless-drivers-next patches for v5.11

    First set of patches for v5.11. rtw88 getting improvements to work
    better with Bluetooth and other driver also getting some new features.
    mhi-ath11k-immutable branch was pulled from mhi tree to avoid
    conflicts with mhi tree.

    Major changes:

    rtw88
    * major bluetooth co-existance improvements
    wilc1000
    * Wi-Fi Multimedia (WMM) support
    ath11k
    * Fast Initial Link Setup (FILS) discovery and unsolicited broadcast
    probe response support
    * qcom,ath11k-calibration-variant Device Tree setting
    * cold boot calibration support
    * new DFS region: JP
    wnc36xx
    * enable connection monitoring and keepalive in firmware
    ath10k
    * firmware IRAM recovery feature
    mhi
    * merge mhi-ath11k-immutable branch to make MHI API change go smoothly

    * tag 'wireless-drivers-next-2020-12-03' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next: (180 commits)
    wl1251: remove trailing semicolon in macro definition
    airo: remove trailing semicolon in macro definition
    wilc1000: added queue support for WMM
    wilc1000: call complete() for failure in wilc_wlan_txq_add_cfg_pkt()
    wilc1000: free resource in wilc_wlan_txq_add_mgmt_pkt() for failure path
    wilc1000: free resource in wilc_wlan_txq_add_net_pkt() for failure path
    wilc1000: added 'ndo_set_mac_address' callback support
    brcmfmac: expose firmware config files through modinfo
    wlcore: Switch to using the new API kobj_to_dev()
    rtw88: coex: add feature to enhance HID coexistence performance
    rtw88: coex: upgrade coexistence A2DP mechanism
    rtw88: coex: add action for coexistence in hardware initial
    rtw88: coex: add function to avoid cck lock
    rtw88: coex: change the coexistence mechanism for WLAN connected
    rtw88: coex: change the coexistence mechanism for HID
    rtw88: coex: update AFH information while in free-run mode
    rtw88: coex: update the mechanism for A2DP + PAN
    rtw88: coex: add debug message
    rtw88: coex: run coexistence when WLAN entering/leaving LPS
    Revert "rtl8xxxu: Add Buffalo WI-U3-866D to list of supported devices"
    ...
    ====================

    Link: https://lore.kernel.org/r/20201203185732.9CFA5C433ED@smtp.codeaurora.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

    Jakub Kicinski
     

20 Nov, 2020

1 commit

  • Reset MHI device channels when driver remove is called due to
    module unload or any crash scenario. This will make sure that
    MHI channels no longer remain enabled for transfers since the
    MHI stack does not take care of this anymore after the auto-start
    channels feature was removed.

    Signed-off-by: Bhaumik Bhatt
    Acked-by: Jakub Kicinski
    Reviewed-by: Manivannan Sadhasivam
    Signed-off-by: Manivannan Sadhasivam

    Bhaumik Bhatt
     

18 Nov, 2020

1 commit


12 Nov, 2020

5 commits

  • Distant QRTR nodes can be accessed via an other node that acts as
    a bridge. When the a QRTR endpoint associated to a bridge node is
    released, all the linked distant nodes should also be released.

    This patch fixes endpoint release by:
    - Submitting QRTR BYE message locally on behalf of all the nodes
    accessible through the endpoint.
    - Removing all the routable node IDs from radix tree pointing to
    the released node endpoint.

    Signed-off-by: Loic Poulain
    Signed-off-by: Jakub Kicinski

    Loic Poulain
     
  • This will be requested for allocating control packet in atomic context.

    Signed-off-by: Loic Poulain
    Signed-off-by: Jakub Kicinski

    Loic Poulain
     
  • In order to reach non-immediate remote node services that are
    accessed through an intermediate node, the route to the remote
    node needs to be saved.

    E.g for a [node1 node2 node3] network
    - node2 forwards node3 service to node1
    - node1 must save node2 as route for reaching node3

    Signed-off-by: Loic Poulain
    Reviewed-by: Bjorn Andersson
    Signed-off-by: Jakub Kicinski

    Loic Poulain
     
  • A remote endpoint (immediate neighbors node) can forward services
    from other nodes (non-immadiate), in that case ctrl packet node ID
    (offering distant service) can differ from the qrtr source node
    (forwarding the packet).

    Signed-off-by: Loic Poulain
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Manivannan Sadhasivam
    Signed-off-by: Jakub Kicinski

    Loic Poulain
     
  • The port ID for control messages was uncorrectly set with broadcast
    node ID value, causing message to be dropped on remote side since
    not passing packet filtering (cb->dst_port != QRTR_PORT_CTRL).

    Fixes: d27e77a3de28 ("net: qrtr: Reset the node and port ID of broadcast messages")
    Signed-off-by: Loic Poulain
    Signed-off-by: Jakub Kicinski

    Loic Poulain
     

06 Oct, 2020

1 commit

  • The rcu_read_lock() is not supposed to lock the kernel_sendmsg() API
    since it has the lock_sock() in qrtr_sendmsg() which will sleep. Hence,
    fix it by excluding the locking for kernel_sendmsg().

    While at it, let's also use radix_tree_deref_retry() to confirm the
    validity of the pointer returned by radix_tree_deref_slot() and use
    radix_tree_iter_resume() to resume iterating the tree properly before
    releasing the lock as suggested by Doug.

    Fixes: a7809ff90ce6 ("net: qrtr: ns: Protect radix_tree_deref_slot() using rcu read locks")
    Reported-by: Douglas Anderson
    Reviewed-by: Douglas Anderson
    Tested-by: Douglas Anderson
    Tested-by: Alex Elder
    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     

29 Sep, 2020

1 commit

  • The rcu read locks are needed to avoid potential race condition while
    dereferencing radix tree from multiple threads. The issue was identified
    by syzbot. Below is the crash report:

    =============================
    WARNING: suspicious RCU usage
    5.7.0-syzkaller #0 Not tainted
    -----------------------------
    include/linux/radix-tree.h:176 suspicious rcu_dereference_check() usage!

    other info that might help us debug this:

    rcu_scheduler_active = 2, debug_locks = 1
    2 locks held by kworker/u4:1/21:
    #0: ffff88821b097938 ((wq_completion)qrtr_ns_handler){+.+.}-{0:0}, at: spin_unlock_irq include/linux/spinlock.h:403 [inline]
    #0: ffff88821b097938 ((wq_completion)qrtr_ns_handler){+.+.}-{0:0}, at: process_one_work+0x6df/0xfd0 kernel/workqueue.c:2241
    #1: ffffc90000dd7d80 ((work_completion)(&qrtr_ns.work)){+.+.}-{0:0}, at: process_one_work+0x71e/0xfd0 kernel/workqueue.c:2243

    stack backtrace:
    CPU: 0 PID: 21 Comm: kworker/u4:1 Not tainted 5.7.0-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Workqueue: qrtr_ns_handler qrtr_ns_worker
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1e9/0x30e lib/dump_stack.c:118
    radix_tree_deref_slot include/linux/radix-tree.h:176 [inline]
    ctrl_cmd_new_lookup net/qrtr/ns.c:558 [inline]
    qrtr_ns_worker+0x2aff/0x4500 net/qrtr/ns.c:674
    process_one_work+0x76e/0xfd0 kernel/workqueue.c:2268
    worker_thread+0xa7f/0x1450 kernel/workqueue.c:2414
    kthread+0x353/0x380 kernel/kthread.c:268

    Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
    Reported-and-tested-by: syzbot+0f84f6eed90503da72fc@syzkaller.appspotmail.com
    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     

10 Sep, 2020

1 commit

  • If skb_put_padto() returns an error, skb has been freed.
    Better not touch it anymore, as reported by syzbot [1]

    Note to qrtr maintainers : this suggests qrtr_sendmsg()
    should adjust sock_alloc_send_skb() second parameter
    to account for the potential added alignment to avoid
    reallocation.

    [1]

    BUG: KASAN: use-after-free in __skb_insert include/linux/skbuff.h:1907 [inline]
    BUG: KASAN: use-after-free in __skb_queue_before include/linux/skbuff.h:2016 [inline]
    BUG: KASAN: use-after-free in __skb_queue_tail include/linux/skbuff.h:2049 [inline]
    BUG: KASAN: use-after-free in skb_queue_tail+0x6b/0x120 net/core/skbuff.c:3146
    Write of size 8 at addr ffff88804d8ab3c0 by task syz-executor.4/4316

    CPU: 1 PID: 4316 Comm: syz-executor.4 Not tainted 5.9.0-rc4-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+0x1d6/0x29e lib/dump_stack.c:118
    print_address_description+0x66/0x620 mm/kasan/report.c:383
    __kasan_report mm/kasan/report.c:513 [inline]
    kasan_report+0x132/0x1d0 mm/kasan/report.c:530
    __skb_insert include/linux/skbuff.h:1907 [inline]
    __skb_queue_before include/linux/skbuff.h:2016 [inline]
    __skb_queue_tail include/linux/skbuff.h:2049 [inline]
    skb_queue_tail+0x6b/0x120 net/core/skbuff.c:3146
    qrtr_tun_send+0x1a/0x40 net/qrtr/tun.c:23
    qrtr_node_enqueue+0x44f/0xc00 net/qrtr/qrtr.c:364
    qrtr_bcast_enqueue+0xbe/0x140 net/qrtr/qrtr.c:861
    qrtr_sendmsg+0x680/0x9c0 net/qrtr/qrtr.c:960
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg net/socket.c:671 [inline]
    sock_write_iter+0x317/0x470 net/socket.c:998
    call_write_iter include/linux/fs.h:1882 [inline]
    new_sync_write fs/read_write.c:503 [inline]
    vfs_write+0xa96/0xd10 fs/read_write.c:578
    ksys_write+0x11b/0x220 fs/read_write.c:631
    do_syscall_64+0x31/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:00007f84b5b81c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
    RAX: ffffffffffffffda RBX: 0000000000038b40 RCX: 000000000045d5b9
    RDX: 0000000000000055 RSI: 0000000020001240 RDI: 0000000000000003
    RBP: 00007f84b5b81ca0 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000000f
    R13: 00007ffcbbf86daf R14: 00007f84b5b829c0 R15: 000000000118cf4c

    Allocated by task 4316:
    kasan_save_stack mm/kasan/common.c:48 [inline]
    kasan_set_track mm/kasan/common.c:56 [inline]
    __kasan_kmalloc+0x100/0x130 mm/kasan/common.c:461
    slab_post_alloc_hook+0x3e/0x290 mm/slab.h:518
    slab_alloc mm/slab.c:3312 [inline]
    kmem_cache_alloc+0x1c1/0x2d0 mm/slab.c:3482
    skb_clone+0x1b2/0x370 net/core/skbuff.c:1449
    qrtr_bcast_enqueue+0x6d/0x140 net/qrtr/qrtr.c:857
    qrtr_sendmsg+0x680/0x9c0 net/qrtr/qrtr.c:960
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg net/socket.c:671 [inline]
    sock_write_iter+0x317/0x470 net/socket.c:998
    call_write_iter include/linux/fs.h:1882 [inline]
    new_sync_write fs/read_write.c:503 [inline]
    vfs_write+0xa96/0xd10 fs/read_write.c:578
    ksys_write+0x11b/0x220 fs/read_write.c:631
    do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Freed by task 4316:
    kasan_save_stack mm/kasan/common.c:48 [inline]
    kasan_set_track+0x3d/0x70 mm/kasan/common.c:56
    kasan_set_free_info+0x17/0x30 mm/kasan/generic.c:355
    __kasan_slab_free+0xdd/0x110 mm/kasan/common.c:422
    __cache_free mm/slab.c:3418 [inline]
    kmem_cache_free+0x82/0xf0 mm/slab.c:3693
    __skb_pad+0x3f5/0x5a0 net/core/skbuff.c:1823
    __skb_put_padto include/linux/skbuff.h:3233 [inline]
    skb_put_padto include/linux/skbuff.h:3252 [inline]
    qrtr_node_enqueue+0x62f/0xc00 net/qrtr/qrtr.c:360
    qrtr_bcast_enqueue+0xbe/0x140 net/qrtr/qrtr.c:861
    qrtr_sendmsg+0x680/0x9c0 net/qrtr/qrtr.c:960
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg net/socket.c:671 [inline]
    sock_write_iter+0x317/0x470 net/socket.c:998
    call_write_iter include/linux/fs.h:1882 [inline]
    new_sync_write fs/read_write.c:503 [inline]
    vfs_write+0xa96/0xd10 fs/read_write.c:578
    ksys_write+0x11b/0x220 fs/read_write.c:631
    do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    The buggy address belongs to the object at ffff88804d8ab3c0
    which belongs to the cache skbuff_head_cache of size 224
    The buggy address is located 0 bytes inside of
    224-byte region [ffff88804d8ab3c0, ffff88804d8ab4a0)
    The buggy address belongs to the page:
    page:00000000ea8cccfb refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88804d8abb40 pfn:0x4d8ab
    flags: 0xfffe0000000200(slab)
    raw: 00fffe0000000200 ffffea0002237ec8 ffffea00029b3388 ffff88821bb66800
    raw: ffff88804d8abb40 ffff88804d8ab000 000000010000000b 0000000000000000
    page dumped because: kasan: bad access detected

    Fixes: ce57785bf91b ("net: qrtr: fix len of skb_put_padto in qrtr_node_enqueue")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Cc: Carl Huang
    Cc: Wen Gong
    Cc: Bjorn Andersson
    Cc: Manivannan Sadhasivam
    Acked-by: Manivannan Sadhasivam
    Reviewed-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Eric Dumazet
     

18 Aug, 2020

1 commit

  • Passing large uint32 sockaddr_qrtr.port numbers for port allocation
    triggers a warning within idr_alloc() since the port number is cast
    to int, and thus interpreted as a negative number. This leads to
    the rejection of such valid port numbers in qrtr_port_assign() as
    idr_alloc() fails.

    To avoid the problem, switch to idr_alloc_u32() instead.

    Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
    Reported-by: syzbot+f31428628ef672716ea8@syzkaller.appspotmail.com
    Signed-off-by: Necip Fazil Yildiran
    Reviewed-by: Dmitry Vyukov
    Signed-off-by: David S. Miller

    Necip Fazil Yildiran
     

26 Jul, 2020

1 commit

  • The UDP reuseport conflict was a little bit tricky.

    The net-next code, via bpf-next, extracted the reuseport handling
    into a helper so that the BPF sk lookup code could invoke it.

    At the same time, the logic for reuseport handling of unconnected
    sockets changed via commit efc6b6f6c3113e8b203b9debfb72d81e0f3dcace
    which changed the logic to carry on the reuseport result into the
    rest of the lookup loop if we do not return immediately.

    This requires moving the reuseport_has_conns() logic into the callers.

    While we are here, get rid of inline directives as they do not belong
    in foo.c files.

    The other changes were cases of more straightforward overlapping
    modifications.

    Signed-off-by: David S. Miller

    David S. Miller
     

25 Jul, 2020

1 commit

  • We have to detach sock from socket in qrtr_release(),
    otherwise skb->sk may still reference to this socket
    when the skb is released in tun->queue, particularly
    sk->sk_wq still points to &sock->wq, which leads to
    a UAF.

    Reported-and-tested-by: syzbot+6720d64f31c081c2f708@syzkaller.appspotmail.com
    Fixes: 28fb4e59a47d ("net: qrtr: Expose tunneling endpoint to user space")
    Cc: Bjorn Andersson
    Cc: Eric Dumazet
    Signed-off-by: Cong Wang
    Reviewed-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Cong Wang
     

20 Jul, 2020

1 commit


01 Jul, 2020

2 commits

  • This code assumes that the user passed in enough data for a
    qrtr_hdr_v1 or qrtr_hdr_v2 struct, but it's not necessarily true. If
    the buffer is too small then it will read beyond the end.

    Reported-by: Manivannan Sadhasivam
    Reported-by: syzbot+b8fe393f999a291a9ea6@syzkaller.appspotmail.com
    Fixes: 194ccc88297a ("net: qrtr: Support decoding incoming v2 packets")
    Signed-off-by: Dan Carpenter
    Signed-off-by: David S. Miller

    Dan Carpenter
     
  • The flow is allocated in qrtr_tx_wait, but not freed when qrtr node
    is released. (*slot) becomes NULL after radix_tree_iter_delete is
    called in __qrtr_node_release. The fix is to save (*slot) to a
    vairable and then free it.

    This memory leak is catched when kmemleak is enabled in kernel,
    the report looks like below:

    unreferenced object 0xffffa0de69e08420 (size 32):
    comm "kworker/u16:3", pid 176, jiffies 4294918275 (age 82858.876s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 28 84 e0 69 de a0 ff ff ........(..i....
    28 84 e0 69 de a0 ff ff 03 00 00 00 00 00 00 00 (..i............
    backtrace:
    [] qrtr_node_enqueue+0x38e/0x400 [qrtr]
    [] qrtr_sendmsg+0x1e0/0x2a0 [qrtr]
    [] sock_sendmsg+0x5b/0x60
    [] qmi_send_message.isra.3+0xbe/0x110 [qmi_helpers]
    [] qmi_send_request+0x1c/0x20 [qmi_helpers]

    Signed-off-by: Carl Huang
    Signed-off-by: David S. Miller

    Carl Huang
     

14 Jun, 2020

1 commit

  • Since commit 84af7a6194e4 ("checkpatch: kconfig: prefer 'help' over
    '---help---'"), the number of '---help---' has been gradually
    decreasing, but there are still more than 2400 instances.

    This commit finishes the conversion. While I touched the lines,
    I also fixed the indentation.

    There are a variety of indentation styles found.

    a) 4 spaces + '---help---'
    b) 7 spaces + '---help---'
    c) 8 spaces + '---help---'
    d) 1 space + 1 tab + '---help---'
    e) 1 tab + '---help---' (correct indentation)
    f) 1 tab + 1 space + '---help---'
    g) 1 tab + 2 spaces + '---help---'

    In order to convert all of them to 1 tab + 'help', I ran the
    following commend:

    $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

01 Jun, 2020

1 commit

  • xdp_umem.c had overlapping changes between the 64-bit math fix
    for the calculation of npgs and the removal of the zerocopy
    memory type which got rid of the chunk_size_nohdr member.

    The mlx5 Kconfig conflict is a case where we just take the
    net-next copy of the Kconfig entry dependency as it takes on
    the ESWITCH dependency by one level of indirection which is
    what the 'net' conflicting change is trying to ensure.

    Signed-off-by: David S. Miller

    David S. Miller
     

31 May, 2020

1 commit

  • A null pointer dereference in qrtr_ns_data_ready() is seen if a client
    opens a qrtr socket before qrtr_ns_init() can bind to the control port.
    When the control port is bound, the ENETRESET error will be broadcasted
    and clients will close their sockets. This results in DEL_CLIENT
    packets being sent to the ns and qrtr_ns_data_ready() being called
    without the workqueue being allocated.

    Allocate the workqueue before setting sk_data_ready and binding to the
    control port. This ensures that the work and workqueue structs are
    allocated and initialized before qrtr_ns_data_ready can be called.

    Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
    Signed-off-by: Chris Lew
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Chris Lew
     

25 May, 2020

1 commit


22 May, 2020

1 commit

  • Once the traversal of the list is completed with list_for_each_entry(),
    the iterator (node) will point to an invalid object. So passing this to
    qrtr_local_enqueue() which is outside of the iterator block is erroneous
    eventhough the object is not used.

    So fix this by passing NULL to qrtr_local_enqueue().

    Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
    Reported-by: kbuild test robot
    Reported-by: Julia Lawall
    Signed-off-by: Manivannan Sadhasivam
    Reviewed-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     

08 May, 2020

2 commits

  • IPC Router protocol is also used by external modems for exchanging the QMI
    messages. Hence, it doesn't always depend on Qualcomm platforms. One such
    instance is the QCA6390 WLAN device connected to x86 machine.

    Reviewed-by: Bjorn Andersson
    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     
  • MHI is the transport layer used for communicating to the external modems.
    Hence, this commit adds MHI transport layer support to QRTR for
    transferring the QMI messages over IPC Router.

    Reviewed-by: Bjorn Andersson
    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     

23 Apr, 2020

1 commit

  • Add tracepoint support for QRTR with NS as the first candidate. Later on
    this can be extended to core QRTR and transport drivers.

    The trace_printk() used in NS has been replaced by tracepoints.

    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     

10 Apr, 2020

1 commit

  • If the local node id(qrtr_local_nid) is not modified after its
    initialization, it equals to the broadcast node id(QRTR_NODE_BCAST).
    So the messages from local node should not be taken as broadcast
    and keep the process going to send them out anyway.

    The definitions are as follow:
    static unsigned int qrtr_local_nid = NUMA_NO_NODE;

    Fixes: fdf5fd397566 ("net: qrtr: Broadcast messages only from control port")
    Signed-off-by: Wang Wenhu
    Signed-off-by: David S. Miller

    Wang Wenhu
     

04 Mar, 2020

2 commits

  • The 2 second delay before calling qrtr_ns_init() meant that the remote
    processors would register as endpoints in qrtr and the say_hello() call
    would therefor broadcast the outgoing HELLO to them. With the HELLO
    handshake corrected this delay is no longer needed.

    Reviewed-by: Manivannan Sadhasivam
    Tested-by: Manivannan Sadhasivam
    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     
  • Lost in the translation from the user space implementation was the
    detail that HELLO mesages must be exchanged between each node pair. As
    such the incoming HELLO must be replied to.

    Similar to the previous implementation no effort is made to prevent two
    Linux boxes from continuously sending HELLO messages back and forth,
    this is left to a follow up patch.

    say_hello() is moved, to facilitate the new call site.

    Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
    Reviewed-by: Manivannan Sadhasivam
    Tested-by: Manivannan Sadhasivam
    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     

27 Feb, 2020

1 commit


25 Feb, 2020

1 commit


22 Feb, 2020

2 commits

  • In order to start the QRTR nameservice, the local node ID needs to be
    valid. Hence, fix it to 1. Previously, the node ID was configured through
    a userspace tool before starting the nameservice daemon. Since we have now
    integrated the nameservice handling to kernel, this change is necessary
    for making it functional.

    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     
  • The QRTR nameservice has been maintained in userspace for some time. This
    commit migrates it to Linux kernel. This change is required in order to
    eliminate the need of starting a userspace daemon for making the WiFi
    functional for ath11k based devices. Since the QRTR NS is not usually
    packed in most of the distros, users need to clone, build and install it
    to get the WiFi working. It will become a hassle when the user doesn't
    have any other source of network connectivity.

    Signed-off-by: Manivannan Sadhasivam
    Signed-off-by: David S. Miller

    Manivannan Sadhasivam
     

15 Jan, 2020

5 commits

  • Rather than enqueuing messages and scheduling a worker to deliver them
    to the individual sockets we can now, thanks to the previous work, move
    this directly into the endpoint callback.

    This saves us a context switch per incoming message and removes the
    possibility of an opportunistic suspend to happen between the message is
    coming from the endpoint until it ends up in the socket's receive
    buffer.

    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     
  • The important part of qrtr_port_lookup() wrt synchronization is that the
    function returns a reference counted struct qrtr_sock, or fail.

    As such we need only to ensure that an decrement of the object's
    refcount happens inbetween the finding of the object in the idr and
    qrtr_port_lookup()'s own increment of the object.

    By using RCU and putting a synchronization point after we remove the
    mapping from the idr, but before it can be released we achieve this -
    with the benefit of not having to hold the mutex in qrtr_port_lookup().

    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     
  • Move operations on the qrtr_nodes radix tree under a separate spinlock
    and make the qrtr_nodes tree GFP_ATOMIC, to allow operation from atomic
    context in a subsequent patch.

    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     
  • In order to prevent overconsumption of resources on the remote side QRTR
    implements a flow control mechanism.

    The mechanism works by the sender keeping track of the number of
    outstanding unconfirmed messages that has been transmitted to a
    particular node/port pair.

    Upon count reaching a low watermark (L) the confirm_rx bit is set in the
    outgoing message and when the count reaching a high watermark (H)
    transmission will be blocked upon the reception of a resume_tx message
    from the remote, that resets the counter to 0.

    This guarantees that there will be at most 2H - L messages in flight.
    Values chosen for L and H are 5 and 10 respectively.

    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     
  • The confirm-rx bit is used to implement a per port flow control, in
    order to make sure that no messages are dropped due to resource
    exhaustion. Move the resume-tx transmission to recvmsg to only confirm
    messages as they are consumed by the application.

    Signed-off-by: Bjorn Andersson
    Signed-off-by: David S. Miller

    Bjorn Andersson
     

06 Jan, 2020

1 commit

  • The len used for skb_put_padto is wrong, it need to add len of hdr.

    In qrtr_node_enqueue, local variable size_t len is assign with
    skb->len, then skb_push(skb, sizeof(*hdr)) will add skb->len with
    sizeof(*hdr), so local variable size_t len is not same with skb->len
    after skb_push(skb, sizeof(*hdr)).

    Then the purpose of skb_put_padto(skb, ALIGN(len, 4)) is to add add
    pad to the end of the skb's data if skb->len is not aligned to 4, but
    unfortunately it use len instead of skb->len, at this line, skb->len
    is 32 bytes(sizeof(*hdr)) more than len, for example, len is 3 bytes,
    then skb->len is 35 bytes(3 + 32), and ALIGN(len, 4) is 4 bytes, so
    __skb_put_padto will do nothing after check size(35) < len(4), the
    correct value should be 36(sizeof(*hdr) + ALIGN(len, 4) = 32 + 4),
    then __skb_put_padto will pass check size(35) < len(36) and add 1 byte
    to the end of skb's data, then logic is correct.

    function of skb_push:
    void *skb_push(struct sk_buff *skb, unsigned int len)
    {
    skb->data -= len;
    skb->len += len;
    if (unlikely(skb->data < skb->head))
    skb_under_panic(skb, len, __builtin_return_address(0));
    return skb->data;
    }

    function of skb_put_padto
    static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
    {
    return __skb_put_padto(skb, len, true);
    }

    function of __skb_put_padto
    static inline int __skb_put_padto(struct sk_buff *skb, unsigned int len,
    bool free_on_error)
    {
    unsigned int size = skb->len;

    if (unlikely(size < len)) {
    len -= size;
    if (__skb_pad(skb, len, free_on_error))
    return -ENOMEM;
    __skb_put(skb, len);
    }
    return 0;
    }

    Signed-off-by: Carl Huang
    Signed-off-by: Wen Gong
    Signed-off-by: David S. Miller

    Carl Huang