1. 01 7月, 2022 32 次提交
  2. 30 6月, 2022 8 次提交
    • P
      Merge branch 'net-neigh-introduce-interval_probe_time-for-periodic-probe' · bf48c3fa
      Paolo Abeni 提交于
      Yuwei Wang says:
      
      ====================
      net, neigh: introduce interval_probe_time for periodic probe
      
      This series adds a new option `interval_probe_time_ms` in net, neigh
      for periodic probe, and add a limitation to prevent it set to 0
      ====================
      
      Link: https://lore.kernel.org/r/20220629084832.2842973-1-wangyuweihx@gmail.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      bf48c3fa
    • Y
      net, neigh: introduce interval_probe_time_ms for periodic probe · 211da42e
      Yuwei Wang 提交于
      commit ed6cd6a1 ("net, neigh: Set lower cap for neigh_managed_work rearming")
      fixed a case when DELAY_PROBE_TIME is configured to 0, the processing of the
      system work queue hog CPU to 100%, and further more we should introduce
      a new option used by periodic probe
      Signed-off-by: NYuwei Wang <wangyuweihx@gmail.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      211da42e
    • Y
      sysctl: add proc_dointvec_ms_jiffies_minmax · c381d02b
      Yuwei Wang 提交于
      add proc_dointvec_ms_jiffies_minmax to fit read msecs value to jiffies
      with a limited range of values
      Signed-off-by: NYuwei Wang <wangyuweihx@gmail.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      c381d02b
    • J
      d19b4c52
    • J
      net: sfp: fix memory leak in sfp_probe() · 0a18d802
      Jianglei Nie 提交于
      sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When
      devm_add_action() fails, sfp is not freed, which leads to a memory leak.
      
      We should use devm_add_action_or_reset() instead of devm_add_action().
      Signed-off-by: NJianglei Nie <niejianglei2021@163.com>
      Reviewed-by: NRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Link: https://lore.kernel.org/r/20220629075550.2152003-1-niejianglei2021@163.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      0a18d802
    • P
      mlxsw: spectrum_router: Fix rollback in tunnel next hop init · 665030fd
      Petr Machata 提交于
      In mlxsw_sp_nexthop6_init(), a next hop is always added to the router
      linked list, and mlxsw_sp_nexthop_type_init() is invoked afterwards. When
      that function results in an error, the next hop will not have been removed
      from the linked list. As the error is propagated upwards and the caller
      frees the next hop object, the linked list ends up holding an invalid
      object.
      
      A similar issue comes up with mlxsw_sp_nexthop4_init(), where rollback
      block does exist, however does not include the linked list removal.
      
      Both IPv6 and IPv4 next hops have a similar issue with next-hop counter
      rollbacks. As these were introduced in the same patchset as the next hop
      linked list, include the cleanup in this patch.
      
      Fixes: dbe4598c ("mlxsw: spectrum_router: Keep nexthops in a linked list")
      Fixes: a5390278 ("mlxsw: spectrum: Add support for setting counters on nexthops")
      Signed-off-by: NPetr Machata <petrm@nvidia.com>
      Reviewed-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Link: https://lore.kernel.org/r/20220629070205.803952-1-idosch@nvidia.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      665030fd
    • D
      net: rose: fix UAF bugs caused by timer handler · 9cc02ede
      Duoming Zhou 提交于
      There are UAF bugs in rose_heartbeat_expiry(), rose_timer_expiry()
      and rose_idletimer_expiry(). The root cause is that del_timer()
      could not stop the timer handler that is running and the refcount
      of sock is not managed properly.
      
      One of the UAF bugs is shown below:
      
          (thread 1)          |        (thread 2)
                              |  rose_bind
                              |  rose_connect
                              |    rose_start_heartbeat
      rose_release            |    (wait a time)
        case ROSE_STATE_0     |
        rose_destroy_socket   |  rose_heartbeat_expiry
          rose_stop_heartbeat |
          sock_put(sk)        |    ...
        sock_put(sk) // FREE  |
                              |    bh_lock_sock(sk) // USE
      
      The sock is deallocated by sock_put() in rose_release() and
      then used by bh_lock_sock() in rose_heartbeat_expiry().
      
      Although rose_destroy_socket() calls rose_stop_heartbeat(),
      it could not stop the timer that is running.
      
      The KASAN report triggered by POC is shown below:
      
      BUG: KASAN: use-after-free in _raw_spin_lock+0x5a/0x110
      Write of size 4 at addr ffff88800ae59098 by task swapper/3/0
      ...
      Call Trace:
       <IRQ>
       dump_stack_lvl+0xbf/0xee
       print_address_description+0x7b/0x440
       print_report+0x101/0x230
       ? irq_work_single+0xbb/0x140
       ? _raw_spin_lock+0x5a/0x110
       kasan_report+0xed/0x120
       ? _raw_spin_lock+0x5a/0x110
       kasan_check_range+0x2bd/0x2e0
       _raw_spin_lock+0x5a/0x110
       rose_heartbeat_expiry+0x39/0x370
       ? rose_start_heartbeat+0xb0/0xb0
       call_timer_fn+0x2d/0x1c0
       ? rose_start_heartbeat+0xb0/0xb0
       expire_timers+0x1f3/0x320
       __run_timers+0x3ff/0x4d0
       run_timer_softirq+0x41/0x80
       __do_softirq+0x233/0x544
       irq_exit_rcu+0x41/0xa0
       sysvec_apic_timer_interrupt+0x8c/0xb0
       </IRQ>
       <TASK>
       asm_sysvec_apic_timer_interrupt+0x1b/0x20
      RIP: 0010:default_idle+0xb/0x10
      RSP: 0018:ffffc9000012fea0 EFLAGS: 00000202
      RAX: 000000000000bcae RBX: ffff888006660f00 RCX: 000000000000bcae
      RDX: 0000000000000001 RSI: ffffffff843a11c0 RDI: ffffffff843a1180
      RBP: dffffc0000000000 R08: dffffc0000000000 R09: ffffed100da36d46
      R10: dfffe9100da36d47 R11: ffffffff83cf0950 R12: 0000000000000000
      R13: 1ffff11000ccc1e0 R14: ffffffff8542af28 R15: dffffc0000000000
      ...
      Allocated by task 146:
       __kasan_kmalloc+0xc4/0xf0
       sk_prot_alloc+0xdd/0x1a0
       sk_alloc+0x2d/0x4e0
       rose_create+0x7b/0x330
       __sock_create+0x2dd/0x640
       __sys_socket+0xc7/0x270
       __x64_sys_socket+0x71/0x80
       do_syscall_64+0x43/0x90
       entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Freed by task 152:
       kasan_set_track+0x4c/0x70
       kasan_set_free_info+0x1f/0x40
       ____kasan_slab_free+0x124/0x190
       kfree+0xd3/0x270
       __sk_destruct+0x314/0x460
       rose_release+0x2fa/0x3b0
       sock_close+0xcb/0x230
       __fput+0x2d9/0x650
       task_work_run+0xd6/0x160
       exit_to_user_mode_loop+0xc7/0xd0
       exit_to_user_mode_prepare+0x4e/0x80
       syscall_exit_to_user_mode+0x20/0x40
       do_syscall_64+0x4f/0x90
       entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      This patch adds refcount of sock when we use functions
      such as rose_start_heartbeat() and so on to start timer,
      and decreases the refcount of sock when timer is finished
      or deleted by functions such as rose_stop_heartbeat()
      and so on. As a result, the UAF bugs could be mitigated.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NDuoming Zhou <duoming@zju.edu.cn>
      Tested-by: NDuoming Zhou <duoming@zju.edu.cn>
      Link: https://lore.kernel.org/r/20220629002640.5693-1-duoming@zju.edu.cnSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      9cc02ede
    • J
      net: usb: ax88179_178a: Fix packet receiving · f8ebb3ac
      Jose Alonso 提交于
      This patch corrects packet receiving in ax88179_rx_fixup.
      
      - problem observed:
        ifconfig shows allways a lot of 'RX Errors' while packets
        are received normally.
      
        This occurs because ax88179_rx_fixup does not recognise properly
        the usb urb received.
        The packets are normally processed and at the end, the code exits
        with 'return 0', generating RX Errors.
        (pkt_cnt==-2 and ptk_hdr over field rx_hdr trying to identify
         another packet there)
      
        This is a usb urb received by "tcpdump -i usbmon2 -X" on a
        little-endian CPU:
        0x0000:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
                 ^         packet 1 start (pkt_len = 0x05ec)
                 ^^^^      IP alignment pseudo header
                      ^    ethernet packet start
                 last byte ethernet packet   v
                 padding (8-bytes aligned)     vvvv vvvv
        0x05e0:  c92d d444 1420 8a69 83dd 272f e82b 9811
        0x05f0:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
        ...      ^ packet 2
        0x0be0:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
        ...
        0x1130:  9d41 9171 8a38 0ec5 eeee f8e3 3b19 87a0
        ...
        0x1720:  8cfc 15ff 5e4c e85c eeee f8e3 3b19 87a0
        ...
        0x1d10:  ecfa 2a3a 19ab c78c eeee f8e3 3b19 87a0
        ...
        0x2070:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
        ...      ^ packet 7
        0x2120:  7c88 4ca5 5c57 7dcc 0d34 7577 f778 7e0a
        0x2130:  f032 e093 7489 0740 3008 ec05 0000 0080
                                     ====1==== ====2====
                 hdr_off             ^
                 pkt_len = 0x05ec         ^^^^
                 AX_RXHDR_*=0x00830  ^^^^   ^
                 pkt_len = 0                        ^^^^
                 AX_RXHDR_DROP_ERR=0x80000000  ^^^^   ^
        0x2140:  3008 ec05 0000 0080 3008 5805 0000 0080
        0x2150:  3008 ec05 0000 0080 3008 ec05 0000 0080
        0x2160:  3008 5803 0000 0080 3008 c800 0000 0080
                 ===11==== ===12==== ===13==== ===14====
        0x2170:  0000 0000 0e00 3821
                           ^^^^ ^^^^ rx_hdr
                           ^^^^      pkt_cnt=14
                                ^^^^ hdr_off=0x2138
                 ^^^^ ^^^^           padding
      
        The dump shows that pkt_cnt is the number of entrys in the
        per-packet metadata. It is "2 * packet count".
        Each packet have two entrys. The first have a valid
        value (pkt_len and AX_RXHDR_*) and the second have a
        dummy-header 0x80000000 (pkt_len=0 with AX_RXHDR_DROP_ERR).
        Why exists dummy-header for each packet?!?
        My guess is that this was done probably to align the
        entry for each packet to 64-bits and maintain compatibility
        with old firmware.
        There is also a padding (0x00000000) before the rx_hdr to
        align the end of rx_hdr to 64-bit.
        Note that packets have a alignment of 64-bits (8-bytes).
      
        This patch assumes that the dummy-header and the last
        padding are optional. So it preserves semantics and
        recognises the same valid packets as the current code.
      
        This patch was made using only the dumpfile information and
        tested with only one device:
        0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
      
      Fixes: 57bc3d3a ("net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup")
      Fixes: e2ca90c2 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
      Signed-off-by: NJose Alonso <joalonsof@gmail.com>
      Acked-by: NPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/d6970bb04bf67598af4d316eaeb1792040b18cfd.camel@gmail.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      f8ebb3ac