1. 14 Jan, 2023 4 commits
    • Clément Léger's avatar
      net: lan966x: add missing fwnode_handle_put() for ports node · 925f3deb
      Clément Léger authored
      Since the "ethernet-ports" node is retrieved using
      device_get_named_child_node(), it should be release after using it. Add
      missing fwnode_handle_put() and move the code that retrieved the node
      from device-tree to avoid complicated handling in case of error.
      
      Fixes: db8bcaad ("net: lan966x: add the basic lan966x driver")
      Signed-off-by: default avatarClément Léger <clement.leger@bootlin.com>
      Reviewed-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
      Link: https://lore.kernel.org/r/20230112161311.495124-1-clement.leger@bootlin.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      925f3deb
    • Vladimir Oltean's avatar
      net: enetc: avoid deadlock in enetc_tx_onestep_tstamp() · 3c463721
      Vladimir Oltean authored
      This lockdep splat says it better than I could:
      
      ================================
      WARNING: inconsistent lock state
      6.2.0-rc2-07010-ga9b9500ffaac-dirty #967 Not tainted
      --------------------------------
      inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
      kworker/1:3/179 [HC0[0]:SC0[0]:HE1:SE1] takes:
      ffff3ec4036ce098 (_xmit_ETHER#2){+.?.}-{3:3}, at: netif_freeze_queues+0x5c/0xc0
      {IN-SOFTIRQ-W} state was registered at:
        _raw_spin_lock+0x5c/0xc0
        sch_direct_xmit+0x148/0x37c
        __dev_queue_xmit+0x528/0x111c
        ip6_finish_output2+0x5ec/0xb7c
        ip6_finish_output+0x240/0x3f0
        ip6_output+0x78/0x360
        ndisc_send_skb+0x33c/0x85c
        ndisc_send_rs+0x54/0x12c
        addrconf_rs_timer+0x154/0x260
        call_timer_fn+0xb8/0x3a0
        __run_timers.part.0+0x214/0x26c
        run_timer_softirq+0x3c/0x74
        __do_softirq+0x14c/0x5d8
        ____do_softirq+0x10/0x20
        call_on_irq_stack+0x2c/0x5c
        do_softirq_own_stack+0x1c/0x30
        __irq_exit_rcu+0x168/0x1a0
        irq_exit_rcu+0x10/0x40
        el1_interrupt+0x38/0x64
      irq event stamp: 7825
      hardirqs last  enabled at (7825): [<ffffdf1f7200cae4>] exit_to_kernel_mode+0x34/0x130
      hardirqs last disabled at (7823): [<ffffdf1f708105f0>] __do_softirq+0x550/0x5d8
      softirqs last  enabled at (7824): [<ffffdf1f7081050c>] __do_softirq+0x46c/0x5d8
      softirqs last disabled at (7811): [<ffffdf1f708166e0>] ____do_softirq+0x10/0x20
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
      
             CPU0
             ----
        lock(_xmit_ETHER#2);
        <Interrupt>
          lock(_xmit_ETHER#2);
      
       *** DEADLOCK ***
      
      3 locks held by kworker/1:3/179:
       #0: ffff3ec400004748 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x1f4/0x6c0
       #1: ffff80000a0bbdc8 ((work_completion)(&priv->tx_onestep_tstamp)){+.+.}-{0:0}, at: process_one_work+0x1f4/0x6c0
       #2: ffff3ec4036cd438 (&dev->tx_global_lock){+.+.}-{3:3}, at: netif_tx_lock+0x1c/0x34
      
      Workqueue: events enetc_tx_onestep_tstamp
      Call trace:
       print_usage_bug.part.0+0x208/0x22c
       mark_lock+0x7f0/0x8b0
       __lock_acquire+0x7c4/0x1ce0
       lock_acquire.part.0+0xe0/0x220
       lock_acquire+0x68/0x84
       _raw_spin_lock+0x5c/0xc0
       netif_freeze_queues+0x5c/0xc0
       netif_tx_lock+0x24/0x34
       enetc_tx_onestep_tstamp+0x20/0x100
       process_one_work+0x28c/0x6c0
       worker_thread+0x74/0x450
       kthread+0x118/0x11c
      
      but I'll say it anyway: the enetc_tx_onestep_tstamp() work item runs in
      process context, therefore with softirqs enabled (i.o.w., it can be
      interrupted by a softirq). If we hold the netif_tx_lock() when there is
      an interrupt, and the NET_TX softirq then gets scheduled, this will take
      the netif_tx_lock() a second time and deadlock the kernel.
      
      To solve this, use netif_tx_lock_bh(), which blocks softirqs from
      running.
      
      Fixes: 7294380c ("enetc: support PTP Sync packet one-step timestamping")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
      Link: https://lore.kernel.org/r/20230112105440.1786799-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      3c463721
    • Esina Ekaterina's avatar
      net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs · 488e0bf7
      Esina Ekaterina authored
      If uhdlc_priv_tsa != 1 then utdm is not initialized.
      And if ret != NULL then goto undo_uhdlc_init, where
      utdm is dereferenced. Same if dev == NULL.
      
      Found by Astra Linux on behalf of Linux Verification Center
      (linuxtesting.org) with SVACE.
      
      Fixes: 8d68100a ("soc/fsl/qe: fix err handling of ucc_of_parse_tdm")
      Signed-off-by: default avatarEsina Ekaterina <eesina@astralinux.ru>
      Link: https://lore.kernel.org/r/20230112074703.13558-1-eesina@astralinux.ruSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      488e0bf7
    • Jisoo Jang's avatar
      net: nfc: Fix use-after-free in local_cleanup() · 4bb4db7f
      Jisoo Jang authored
      Fix a use-after-free that occurs in kfree_skb() called from
      local_cleanup(). This could happen when killing nfc daemon (e.g. neard)
      after detaching an nfc device.
      When detaching an nfc device, local_cleanup() called from
      nfc_llcp_unregister_device() frees local->rx_pending and decreases
      local->ref by kref_put() in nfc_llcp_local_put().
      In the terminating process, nfc daemon releases all sockets and it leads
      to decreasing local->ref. After the last release of local->ref,
      local_cleanup() called from local_release() frees local->rx_pending
      again, which leads to the bug.
      
      Setting local->rx_pending to NULL in local_cleanup() could prevent
      use-after-free when local_cleanup() is called twice.
      
      Found by a modified version of syzkaller.
      
      BUG: KASAN: use-after-free in kfree_skb()
      
      Call Trace:
      dump_stack_lvl (lib/dump_stack.c:106)
      print_address_description.constprop.0.cold (mm/kasan/report.c:306)
      kasan_check_range (mm/kasan/generic.c:189)
      kfree_skb (net/core/skbuff.c:955)
      local_cleanup (net/nfc/llcp_core.c:159)
      nfc_llcp_local_put.part.0 (net/nfc/llcp_core.c:172)
      nfc_llcp_local_put (net/nfc/llcp_core.c:181)
      llcp_sock_destruct (net/nfc/llcp_sock.c:959)
      __sk_destruct (net/core/sock.c:2133)
      sk_destruct (net/core/sock.c:2181)
      __sk_free (net/core/sock.c:2192)
      sk_free (net/core/sock.c:2203)
      llcp_sock_release (net/nfc/llcp_sock.c:646)
      __sock_release (net/socket.c:650)
      sock_close (net/socket.c:1365)
      __fput (fs/file_table.c:306)
      task_work_run (kernel/task_work.c:179)
      ptrace_notify (kernel/signal.c:2354)
      syscall_exit_to_user_mode_prepare (kernel/entry/common.c:278)
      syscall_exit_to_user_mode (kernel/entry/common.c:296)
      do_syscall_64 (arch/x86/entry/common.c:86)
      entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:106)
      
      Allocated by task 4719:
      kasan_save_stack (mm/kasan/common.c:45)
      __kasan_slab_alloc (mm/kasan/common.c:325)
      slab_post_alloc_hook (mm/slab.h:766)
      kmem_cache_alloc_node (mm/slub.c:3497)
      __alloc_skb (net/core/skbuff.c:552)
      pn533_recv_response (drivers/nfc/pn533/usb.c:65)
      __usb_hcd_giveback_urb (drivers/usb/core/hcd.c:1671)
      usb_giveback_urb_bh (drivers/usb/core/hcd.c:1704)
      tasklet_action_common.isra.0 (kernel/softirq.c:797)
      __do_softirq (kernel/softirq.c:571)
      
      Freed by task 1901:
      kasan_save_stack (mm/kasan/common.c:45)
      kasan_set_track (mm/kasan/common.c:52)
      kasan_save_free_info (mm/kasan/genericdd.c:518)
      __kasan_slab_free (mm/kasan/common.c:236)
      kmem_cache_free (mm/slub.c:3809)
      kfree_skbmem (net/core/skbuff.c:874)
      kfree_skb (net/core/skbuff.c:931)
      local_cleanup (net/nfc/llcp_core.c:159)
      nfc_llcp_unregister_device (net/nfc/llcp_core.c:1617)
      nfc_unregister_device (net/nfc/core.c:1179)
      pn53x_unregister_nfc (drivers/nfc/pn533/pn533.c:2846)
      pn533_usb_disconnect (drivers/nfc/pn533/usb.c:579)
      usb_unbind_interface (drivers/usb/core/driver.c:458)
      device_release_driver_internal (drivers/base/dd.c:1279)
      bus_remove_device (drivers/base/bus.c:529)
      device_del (drivers/base/core.c:3665)
      usb_disable_device (drivers/usb/core/message.c:1420)
      usb_disconnect (drivers/usb/core.c:2261)
      hub_event (drivers/usb/core/hub.c:5833)
      process_one_work (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/workqueue.h:108 kernel/workqueue.c:2281)
      worker_thread (include/linux/list.h:282 kernel/workqueue.c:2423)
      kthread (kernel/kthread.c:319)
      ret_from_fork (arch/x86/entry/entry_64.S:301)
      
      Fixes: 3536da06 ("NFC: llcp: Clean local timers and works when removing a device")
      Signed-off-by: default avatarJisoo Jang <jisoo.jang@yonsei.ac.kr>
      Link: https://lore.kernel.org/r/20230111131914.3338838-1-jisoo.jang@yonsei.ac.krSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4bb4db7f
  2. 13 Jan, 2023 7 commits
  3. 12 Jan, 2023 16 commits
  4. 11 Jan, 2023 13 commits