1. Jul 02, 2022
  2. Jul 01, 2022
  3. Jun 30, 2022
    • Pavel Begunkov's avatar
      io_uring: keep sendrecv flags in ioprio · 29c1ac23
      Pavel Begunkov authored
      
      
      We waste a u64 SQE field for flags even though we don't need as many
      bits and it can be used for something more useful later. Store io_uring
      specific send/recv flags in sqe->ioprio instead of ->addr2.
      
      Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Fixes: 0455d4cc
      
       ("io_uring: add POLL_FIRST support for send/sendmsg and recv/recvmsg")
      [axboe: change comment in io_uring.h as well]
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      29c1ac23
    • Masahiro Yamada's avatar
      s390/purgatory: remove duplicated build rule of kexec-purgatory.o · 20159e28
      Masahiro Yamada authored
      
      
      This is equivalent to the pattern rule in scripts/Makefile.build.
      
      Having the dependency on $(obj)/purgatory.ro is enough.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://lore.kernel.org/r/20220613170902.1775211-3-masahiroy@kernel.org
      
      
      Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      20159e28
    • Masahiro Yamada's avatar
      s390/purgatory: hard-code obj-y in Makefile · b9a56c11
      Masahiro Yamada authored
      
      
      The purgatory/ directory is entirely guarded in arch/s390/Kbuild.
      CONFIG_ARCH_HAS_KEXEC_PURGATORY is bool type.
      
      $(CONFIG_ARCH_HAS_KEXEC_PURGATORY) is always 'y' when Kbuild visits
      this Makefile for building.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://lore.kernel.org/r/20220613170902.1775211-2-masahiroy@kernel.org
      
      
      Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      b9a56c11
    • Masahiro Yamada's avatar
      s390: remove unneeded 'select BUILD_BIN2C' · 25deecb2
      Masahiro Yamada authored
      Since commit 4c0f032d ("s390/purgatory: Omit use of bin2c"),
      s390 builds the purgatory without using bin2c.
      
      Remove 'select BUILD_BIN2C' to avoid the unneeded build of bin2c.
      
      Fixes: 4c0f032d
      
       ("s390/purgatory: Omit use of bin2c")
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://lore.kernel.org/r/20220613170902.1775211-1-masahiroy@kernel.org
      
      
      Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      25deecb2
    • Jianglei Nie's avatar
      net: sfp: fix memory leak in sfp_probe() · 0a18d802
      Jianglei Nie authored
      
      
      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: default avatarJianglei Nie <niejianglei2021@163.com>
      Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Link: https://lore.kernel.org/r/20220629075550.2152003-1-niejianglei2021@163.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      0a18d802
    • Petr Machata's avatar
      mlxsw: spectrum_router: Fix rollback in tunnel next hop init · 665030fd
      Petr Machata authored
      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: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Link: https://lore.kernel.org/r/20220629070205.803952-1-idosch@nvidia.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      665030fd
    • Duoming Zhou's avatar
      net: rose: fix UAF bugs caused by timer handler · 9cc02ede
      Duoming Zhou authored
      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: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Tested-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Link: https://lore.kernel.org/r/20220629002640.5693-1-duoming@zju.edu.cn
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      9cc02ede
    • Jose Alonso's avatar
      net: usb: ax88179_178a: Fix packet receiving · f8ebb3ac
      Jose Alonso authored
      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: default avatarJose Alonso <joalonsof@gmail.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/d6970bb04bf67598af4d316eaeb1792040b18cfd.camel@gmail.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      f8ebb3ac
    • Lamarque Vieira Souza's avatar
      nvme-pci: add NVME_QUIRK_BOGUS_NID for ADATA IM2P33F8ABR1 · e1c70d79
      Lamarque Vieira Souza authored
      
      
      ADATA IM2P33F8ABR1 reports bogus eui64 values that appear to be the same
      across all drives. Quirk them out so they are not marked as "non globally
      unique" duplicates.
      
      Co-developed-by: default avatarFelipe de Jesus Araujo da Conceição <felipe.conceicao@petrosoftdesign.com>
      Signed-off-by: default avatarFelipe de Jesus Araujo da Conceição <felipe.conceicao@petrosoftdesign.com>
      Signed-off-by: default avatarLamarque V. Souza <lamarque.souza@petrosoftdesign.com>
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      e1c70d79