Skip to content
Snippets Groups Projects
  1. Mar 15, 2024
    • Jason Xing's avatar
      netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay · 34c84e00
      Jason Xing authored
      
      [ Upstream commit 806f462b ]
      
      We need to protect the reader reading the sysctl value because the
      value can be changed concurrently.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34c84e00
    • Jason Xing's avatar
      netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries · 34a164d2
      Jason Xing authored
      
      [ Upstream commit e799299a ]
      
      We need to protect the reader reading the sysctl value because the
      value can be changed concurrently.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34a164d2
    • Jason Xing's avatar
      netrom: Fix a data-race around sysctl_netrom_transport_timeout · 291d36d7
      Jason Xing authored
      
      [ Upstream commit 60a7a152 ]
      
      We need to protect the reader reading the sysctl value because the
      value can be changed concurrently.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      291d36d7
    • Jason Xing's avatar
      netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser · d1261bde
      Jason Xing authored
      
      [ Upstream commit 119cae5e ]
      
      We need to protect the reader reading the sysctl value because the
      value can be changed concurrently.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d1261bde
    • Jason Xing's avatar
      netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser · 18c95d11
      Jason Xing authored
      
      [ Upstream commit cfd9f4a7 ]
      
      We need to protect the reader reading the sysctl value
      because the value can be changed concurrently.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18c95d11
    • Jason Xing's avatar
      netrom: Fix a data-race around sysctl_netrom_default_path_quality · e041df5d
      Jason Xing authored
      
      [ Upstream commit 958d6145 ]
      
      We need to protect the reader reading sysctl_netrom_default_path_quality
      because the value can be changed concurrently.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e041df5d
    • Lena Wang's avatar
      netfilter: nf_conntrack_h323: Add protection for bmp length out of range · ccd1108b
      Lena Wang authored
      
      [ Upstream commit 76714663 ]
      
      UBSAN load reports an exception of BRK#5515 SHIFT_ISSUE:Bitwise shifts
      that are out of bounds for their data type.
      
      vmlinux   get_bitmap(b=75) + 712
      <net/netfilter/nf_conntrack_h323_asn1.c:0>
      vmlinux   decode_seq(bs=0xFFFFFFD008037000, f=0xFFFFFFD008037018, level=134443100) + 1956
      <net/netfilter/nf_conntrack_h323_asn1.c:592>
      vmlinux   decode_choice(base=0xFFFFFFD0080370F0, level=23843636) + 1216
      <net/netfilter/nf_conntrack_h323_asn1.c:814>
      vmlinux   decode_seq(f=0xFFFFFFD0080371A8, level=134443500) + 812
      <net/netfilter/nf_conntrack_h323_asn1.c:576>
      vmlinux   decode_choice(base=0xFFFFFFD008037280, level=0) + 1216
      <net/netfilter/nf_conntrack_h323_asn1.c:814>
      vmlinux   DecodeRasMessage() + 304
      <net/netfilter/nf_conntrack_h323_asn1.c:833>
      vmlinux   ras_help() + 684
      <net/netfilter/nf_conntrack_h323_main.c:1728>
      vmlinux   nf_confirm() + 188
      <net/netfilter/nf_conntrack_proto.c:137>
      
      Due to abnormal data in skb->data, the extension bitmap length
      exceeds 32 when decoding ras message then uses the length to make
      a shift operation. It will change into negative after several loop.
      UBSAN load could detect a negative shift as an undefined behaviour
      and reports exception.
      So we add the protection to avoid the length exceeding 32. Or else
      it will return out of range error and stop decoding.
      
      Fixes: 5e35941d ("[NETFILTER]: Add H.323 conntrack/NAT helper")
      Signed-off-by: default avatarLena Wang <lena.wang@mediatek.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ccd1108b
    • Florian Westphal's avatar
      netfilter: nft_ct: fix l3num expectations with inet pseudo family · 2b4e7cb7
      Florian Westphal authored
      
      [ Upstream commit 99993789 ]
      
      Following is rejected but should be allowed:
      
      table inet t {
              ct expectation exp1 {
                      [..]
                      l3proto ip
      
      Valid combos are:
      table ip t, l3proto ip
      table ip6 t, l3proto ip6
      table inet t, l3proto ip OR l3proto ip6
      
      Disallow inet pseudeo family, the l3num must be a on-wire protocol known
      to conntrack.
      
      Retain NFPROTO_INET case to make it clear its rejected
      intentionally rather as oversight.
      
      Fixes: 8059918a ("netfilter: nft_ct: sanitize layer 3 and 4 protocol number in custom expectations")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b4e7cb7
    • Edward Adam Davis's avatar
      net/rds: fix WARNING in rds_conn_connect_if_down · 9dfc15a1
      Edward Adam Davis authored
      
      [ Upstream commit c055fc00 ]
      
      If connection isn't established yet, get_mr() will fail, trigger connection after
      get_mr().
      
      Fixes: 584a8279 ("RDS: RDMA: return appropriate error on rdma map failures")
      Reported-and-tested-by: default avatar <syzbot+d4faee732755bba9838e@syzkaller.appspotmail.com>
      Signed-off-by: default avatarEdward Adam Davis <eadavis@qq.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9dfc15a1
    • Toke Høiland-Jørgensen's avatar
      cpumap: Zero-initialise xdp_rxq_info struct before running XDP program · 5f4e51ab
      Toke Høiland-Jørgensen authored
      
      [ Upstream commit 2487007a ]
      
      When running an XDP program that is attached to a cpumap entry, we don't
      initialise the xdp_rxq_info data structure being used in the xdp_buff
      that backs the XDP program invocation. Tobias noticed that this leads to
      random values being returned as the xdp_md->rx_queue_index value for XDP
      programs running in a cpumap.
      
      This means we're basically returning the contents of the uninitialised
      memory, which is bad. Fix this by zero-initialising the rxq data
      structure before running the XDP program.
      
      Fixes: 92164774 ("bpf: cpumap: Add the possibility to attach an eBPF program to cpumap")
      Reported-by: default avatarTobias Böhm <tobias@aibor.de>
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/r/20240305213132.11955-1-toke@redhat.com
      
      
      Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f4e51ab
    • Eric Dumazet's avatar
      net/ipv6: avoid possible UAF in ip6_route_mpath_notify() · 79ce2e54
      Eric Dumazet authored
      
      [ Upstream commit 685f7d53 ]
      
      syzbot found another use-after-free in ip6_route_mpath_notify() [1]
      
      Commit f7225172 ("net/ipv6: prevent use after free in
      ip6_route_mpath_notify") was not able to fix the root cause.
      
      We need to defer the fib6_info_release() calls after
      ip6_route_mpath_notify(), in the cleanup phase.
      
      [1]
      BUG: KASAN: slab-use-after-free in rt6_fill_node+0x1460/0x1ac0
      Read of size 4 at addr ffff88809a07fc64 by task syz-executor.2/23037
      
      CPU: 0 PID: 23037 Comm: syz-executor.2 Not tainted 6.8.0-rc4-syzkaller-01035-gea7f3cfaa588 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
      Call Trace:
       <TASK>
        __dump_stack lib/dump_stack.c:88 [inline]
        dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106
        print_address_description mm/kasan/report.c:377 [inline]
        print_report+0x167/0x540 mm/kasan/report.c:488
        kasan_report+0x142/0x180 mm/kasan/report.c:601
       rt6_fill_node+0x1460/0x1ac0
        inet6_rt_notify+0x13b/0x290 net/ipv6/route.c:6184
        ip6_route_mpath_notify net/ipv6/route.c:5198 [inline]
        ip6_route_multipath_add net/ipv6/route.c:5404 [inline]
        inet6_rtm_newroute+0x1d0f/0x2300 net/ipv6/route.c:5517
        rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597
        netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
        netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
        netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
        netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg+0x221/0x270 net/socket.c:745
        ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
        ___sys_sendmsg net/socket.c:2638 [inline]
        __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77
      RIP: 0033:0x7f73dd87dda9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 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 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f73de6550c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f73dd9ac050 RCX: 00007f73dd87dda9
      RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000005
      RBP: 00007f73dd8ca47a R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 000000000000006e R14: 00007f73dd9ac050 R15: 00007ffdbdeb7858
       </TASK>
      
      Allocated by task 23037:
        kasan_save_stack mm/kasan/common.c:47 [inline]
        kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
        poison_kmalloc_redzone mm/kasan/common.c:372 [inline]
        __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:389
        kasan_kmalloc include/linux/kasan.h:211 [inline]
        __do_kmalloc_node mm/slub.c:3981 [inline]
        __kmalloc+0x22e/0x490 mm/slub.c:3994
        kmalloc include/linux/slab.h:594 [inline]
        kzalloc include/linux/slab.h:711 [inline]
        fib6_info_alloc+0x2e/0xf0 net/ipv6/ip6_fib.c:155
        ip6_route_info_create+0x445/0x12b0 net/ipv6/route.c:3758
        ip6_route_multipath_add net/ipv6/route.c:5298 [inline]
        inet6_rtm_newroute+0x744/0x2300 net/ipv6/route.c:5517
        rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597
        netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
        netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
        netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
        netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg+0x221/0x270 net/socket.c:745
        ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
        ___sys_sendmsg net/socket.c:2638 [inline]
        __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77
      
      Freed by task 16:
        kasan_save_stack mm/kasan/common.c:47 [inline]
        kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
        kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:640
        poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241
        __kasan_slab_free+0x34/0x70 mm/kasan/common.c:257
        kasan_slab_free include/linux/kasan.h:184 [inline]
        slab_free_hook mm/slub.c:2121 [inline]
        slab_free mm/slub.c:4299 [inline]
        kfree+0x14a/0x380 mm/slub.c:4409
        rcu_do_batch kernel/rcu/tree.c:2190 [inline]
        rcu_core+0xd76/0x1810 kernel/rcu/tree.c:2465
        __do_softirq+0x2bb/0x942 kernel/softirq.c:553
      
      Last potentially related work creation:
        kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
        __kasan_record_aux_stack+0xae/0x100 mm/kasan/generic.c:586
        __call_rcu_common kernel/rcu/tree.c:2715 [inline]
        call_rcu+0x167/0xa80 kernel/rcu/tree.c:2829
        fib6_info_release include/net/ip6_fib.h:341 [inline]
        ip6_route_multipath_add net/ipv6/route.c:5344 [inline]
        inet6_rtm_newroute+0x114d/0x2300 net/ipv6/route.c:5517
        rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597
        netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
        netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
        netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
        netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg+0x221/0x270 net/socket.c:745
        ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
        ___sys_sendmsg net/socket.c:2638 [inline]
        __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77
      
      The buggy address belongs to the object at ffff88809a07fc00
       which belongs to the cache kmalloc-512 of size 512
      The buggy address is located 100 bytes inside of
       freed 512-byte region [ffff88809a07fc00, ffff88809a07fe00)
      
      The buggy address belongs to the physical page:
      page:ffffea0002681f00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x9a07c
      head:ffffea0002681f00 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
      page_type: 0xffffffff()
      raw: 00fff00000000840 ffff888014c41c80 dead000000000122 0000000000000000
      raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 23028, tgid 23027 (syz-executor.4), ts 2340253595219, free_ts 2339107097036
        set_page_owner include/linux/page_owner.h:31 [inline]
        post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533
        prep_new_page mm/page_alloc.c:1540 [inline]
        get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311
        __alloc_pages+0x255/0x680 mm/page_alloc.c:4567
        __alloc_pages_node include/linux/gfp.h:238 [inline]
        alloc_pages_node include/linux/gfp.h:261 [inline]
        alloc_slab_page+0x5f/0x160 mm/slub.c:2190
        allocate_slab mm/slub.c:2354 [inline]
        new_slab+0x84/0x2f0 mm/slub.c:2407
        ___slab_alloc+0xd17/0x13e0 mm/slub.c:3540
        __slab_alloc mm/slub.c:3625 [inline]
        __slab_alloc_node mm/slub.c:3678 [inline]
        slab_alloc_node mm/slub.c:3850 [inline]
        __do_kmalloc_node mm/slub.c:3980 [inline]
        __kmalloc+0x2e0/0x490 mm/slub.c:3994
        kmalloc include/linux/slab.h:594 [inline]
        kzalloc include/linux/slab.h:711 [inline]
        new_dir fs/proc/proc_sysctl.c:956 [inline]
        get_subdir fs/proc/proc_sysctl.c:1000 [inline]
        sysctl_mkdir_p fs/proc/proc_sysctl.c:1295 [inline]
        __register_sysctl_table+0xb30/0x1440 fs/proc/proc_sysctl.c:1376
        neigh_sysctl_register+0x416/0x500 net/core/neighbour.c:3859
        devinet_sysctl_register+0xaf/0x1f0 net/ipv4/devinet.c:2644
        inetdev_init+0x296/0x4d0 net/ipv4/devinet.c:286
        inetdev_event+0x338/0x15c0 net/ipv4/devinet.c:1555
        notifier_call_chain+0x18f/0x3b0 kernel/notifier.c:93
        call_netdevice_notifiers_extack net/core/dev.c:1987 [inline]
        call_netdevice_notifiers net/core/dev.c:2001 [inline]
        register_netdevice+0x15b2/0x1a20 net/core/dev.c:10340
        br_dev_newlink+0x27/0x100 net/bridge/br_netlink.c:1563
        rtnl_newlink_create net/core/rtnetlink.c:3497 [inline]
        __rtnl_newlink net/core/rtnetlink.c:3717 [inline]
        rtnl_newlink+0x158f/0x20a0 net/core/rtnetlink.c:3730
      page last free pid 11583 tgid 11583 stack trace:
        reset_page_owner include/linux/page_owner.h:24 [inline]
        free_pages_prepare mm/page_alloc.c:1140 [inline]
        free_unref_page_prepare+0x968/0xa90 mm/page_alloc.c:2346
        free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
        kasan_depopulate_vmalloc_pte+0x74/0x90 mm/kasan/shadow.c:415
        apply_to_pte_range mm/memory.c:2619 [inline]
        apply_to_pmd_range mm/memory.c:2663 [inline]
        apply_to_pud_range mm/memory.c:2699 [inline]
        apply_to_p4d_range mm/memory.c:2735 [inline]
        __apply_to_page_range+0x8ec/0xe40 mm/memory.c:2769
        kasan_release_vmalloc+0x9a/0xb0 mm/kasan/shadow.c:532
        __purge_vmap_area_lazy+0x163f/0x1a10 mm/vmalloc.c:1770
        drain_vmap_area_work+0x40/0xd0 mm/vmalloc.c:1804
        process_one_work kernel/workqueue.c:2633 [inline]
        process_scheduled_works+0x913/0x1420 kernel/workqueue.c:2706
        worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787
        kthread+0x2ef/0x390 kernel/kthread.c:388
        ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
        ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
      
      Memory state around the buggy address:
       ffff88809a07fb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff88809a07fb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff88809a07fc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
       ffff88809a07fc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff88809a07fd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      
      Fixes: 3b1137fe ("net: ipv6: Change notifications for multipath add to RTA_MULTIPATH")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20240303144801.702646-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      79ce2e54
    • Rand Deeb's avatar
      net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() · 37fe9901
      Rand Deeb authored
      
      [ Upstream commit 06e456a0 ]
      
      The function ice_bridge_setlink() may encounter a NULL pointer dereference
      if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently
      in nla_for_each_nested(). To address this issue, add a check to ensure that
      br_spec is not NULL before proceeding with the nested attribute iteration.
      
      Fixes: b1edc14a ("ice: Implement ice_bridge_getlink and ice_bridge_setlink")
      Signed-off-by: default avatarRand Deeb <rand.sec96@gmail.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      37fe9901
    • Eric Dumazet's avatar
      geneve: make sure to pull inner header in geneve_rx() · c7137900
      Eric Dumazet authored
      
      [ Upstream commit 1ca1ba46 ]
      
      syzbot triggered a bug in geneve_rx() [1]
      
      Issue is similar to the one I fixed in commit 8d975c15
      ("ip6_tunnel: make sure to pull inner header in __ip6_tnl_rcv()")
      
      We have to save skb->network_header in a temporary variable
      in order to be able to recompute the network_header pointer
      after a pskb_inet_may_pull() call.
      
      pskb_inet_may_pull() makes sure the needed headers are in skb->head.
      
      [1]
      BUG: KMSAN: uninit-value in IP_ECN_decapsulate include/net/inet_ecn.h:302 [inline]
       BUG: KMSAN: uninit-value in geneve_rx drivers/net/geneve.c:279 [inline]
       BUG: KMSAN: uninit-value in geneve_udp_encap_recv+0x36f9/0x3c10 drivers/net/geneve.c:391
        IP_ECN_decapsulate include/net/inet_ecn.h:302 [inline]
        geneve_rx drivers/net/geneve.c:279 [inline]
        geneve_udp_encap_recv+0x36f9/0x3c10 drivers/net/geneve.c:391
        udp_queue_rcv_one_skb+0x1d39/0x1f20 net/ipv4/udp.c:2108
        udp_queue_rcv_skb+0x6ae/0x6e0 net/ipv4/udp.c:2186
        udp_unicast_rcv_skb+0x184/0x4b0 net/ipv4/udp.c:2346
        __udp4_lib_rcv+0x1c6b/0x3010 net/ipv4/udp.c:2422
        udp_rcv+0x7d/0xa0 net/ipv4/udp.c:2604
        ip_protocol_deliver_rcu+0x264/0x1300 net/ipv4/ip_input.c:205
        ip_local_deliver_finish+0x2b8/0x440 net/ipv4/ip_input.c:233
        NF_HOOK include/linux/netfilter.h:314 [inline]
        ip_local_deliver+0x21f/0x490 net/ipv4/ip_input.c:254
        dst_input include/net/dst.h:461 [inline]
        ip_rcv_finish net/ipv4/ip_input.c:449 [inline]
        NF_HOOK include/linux/netfilter.h:314 [inline]
        ip_rcv+0x46f/0x760 net/ipv4/ip_input.c:569
        __netif_receive_skb_one_core net/core/dev.c:5534 [inline]
        __netif_receive_skb+0x1a6/0x5a0 net/core/dev.c:5648
        process_backlog+0x480/0x8b0 net/core/dev.c:5976
        __napi_poll+0xe3/0x980 net/core/dev.c:6576
        napi_poll net/core/dev.c:6645 [inline]
        net_rx_action+0x8b8/0x1870 net/core/dev.c:6778
        __do_softirq+0x1b7/0x7c5 kernel/softirq.c:553
        do_softirq+0x9a/0xf0 kernel/softirq.c:454
        __local_bh_enable_ip+0x9b/0xa0 kernel/softirq.c:381
        local_bh_enable include/linux/bottom_half.h:33 [inline]
        rcu_read_unlock_bh include/linux/rcupdate.h:820 [inline]
        __dev_queue_xmit+0x2768/0x51c0 net/core/dev.c:4378
        dev_queue_xmit include/linux/netdevice.h:3171 [inline]
        packet_xmit+0x9c/0x6b0 net/packet/af_packet.c:276
        packet_snd net/packet/af_packet.c:3081 [inline]
        packet_sendmsg+0x8aef/0x9f10 net/packet/af_packet.c:3113
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg net/socket.c:745 [inline]
        __sys_sendto+0x735/0xa10 net/socket.c:2191
        __do_sys_sendto net/socket.c:2203 [inline]
        __se_sys_sendto net/socket.c:2199 [inline]
        __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199
        do_syscall_x64 arch/x86/entry/common.c:52 [inline]
        do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Uninit was created at:
        slab_post_alloc_hook mm/slub.c:3819 [inline]
        slab_alloc_node mm/slub.c:3860 [inline]
        kmem_cache_alloc_node+0x5cb/0xbc0 mm/slub.c:3903
        kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:560
        __alloc_skb+0x352/0x790 net/core/skbuff.c:651
        alloc_skb include/linux/skbuff.h:1296 [inline]
        alloc_skb_with_frags+0xc8/0xbd0 net/core/skbuff.c:6394
        sock_alloc_send_pskb+0xa80/0xbf0 net/core/sock.c:2783
        packet_alloc_skb net/packet/af_packet.c:2930 [inline]
        packet_snd net/packet/af_packet.c:3024 [inline]
        packet_sendmsg+0x70c2/0x9f10 net/packet/af_packet.c:3113
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg net/socket.c:745 [inline]
        __sys_sendto+0x735/0xa10 net/socket.c:2191
        __do_sys_sendto net/socket.c:2203 [inline]
        __se_sys_sendto net/socket.c:2199 [inline]
        __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199
        do_syscall_x64 arch/x86/entry/common.c:52 [inline]
        do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Fixes: 2d07dc79 ("geneve: add initial netdev driver for GENEVE tunnels")
      Reported-and-tested-by: default avatar <syzbot+6a1423ff3f97159aae64@syzkaller.appspotmail.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c7137900
    • Steven Rostedt (Google)'s avatar
      tracing/net_sched: Fix tracepoints that save qdisc_dev() as a string · fdb63c17
      Steven Rostedt (Google) authored
      
      [ Upstream commit 51270d57 ]
      
      I'm updating __assign_str() and will be removing the second parameter. To
      make sure that it does not break anything, I make sure that it matches the
      __string() field, as that is where the string is actually going to be
      saved in. To make sure there's nothing that breaks, I added a WARN_ON() to
      make sure that what was used in __string() is the same that is used in
      __assign_str().
      
      In doing this change, an error was triggered as __assign_str() now expects
      the string passed in to be a char * value. I instead had the following
      warning:
      
      include/trace/events/qdisc.h: In function ‘trace_event_raw_event_qdisc_reset’:
      include/trace/events/qdisc.h:91:35: error: passing argument 1 of 'strcmp' from incompatible pointer type [-Werror=incompatible-pointer-types]
         91 |                 __assign_str(dev, qdisc_dev(q));
      
      That's because the qdisc_enqueue() and qdisc_reset() pass in qdisc_dev(q)
      to __assign_str() and to __string(). But that function returns a pointer
      to struct net_device and not a string.
      
      It appears that these events are just saving the pointer as a string and
      then reading it as a string as well.
      
      Use qdisc_dev(q)->name to save the device instead.
      
      Fixes: a34dac0b ("net_sched: add tracepoints for qdisc_reset() and qdisc_destroy()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Reviewed-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fdb63c17
    • Maciej Fijalkowski's avatar
      i40e: disable NAPI right after disabling irqs when handling xsk_pool · 71e21eb1
      Maciej Fijalkowski authored
      
      [ Upstream commit d562b11c ]
      
      Disable NAPI before shutting down queues that this particular NAPI
      contains so that the order of actions in i40e_queue_pair_disable()
      mirrors what we do in i40e_queue_pair_enable().
      
      Fixes: 123cecd4 ("i40e: added queue pair disable/enable functions")
      Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
      Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      71e21eb1
    • Maciej Fijalkowski's avatar
      ixgbe: {dis, en}able irqs in ixgbe_txrx_ring_{dis, en}able · ad91d5d1
      Maciej Fijalkowski authored
      
      [ Upstream commit cbf996f5 ]
      
      Currently routines that are supposed to toggle state of ring pair do not
      take care of associated interrupt with queue vector that these rings
      belong to. This causes funky issues such as dead interface due to irq
      misconfiguration, as per Pavel's report from Closes: tag.
      
      Add a function responsible for disabling single IRQ in EIMC register and
      call this as a very first thing when disabling ring pair during xsk_pool
      setup. For enable let's reuse ixgbe_irq_enable_queues(). Besides this,
      disable/enable NAPI as first/last thing when dealing with closing or
      opening ring pair that xsk_pool is being configured on.
      
      Reported-by: default avatarPavel Vazharov <pavel@x3me.net>
      Closes: https://lore.kernel.org/netdev/CAJEV1ijxNyPTwASJER1bcZzS9nMoZJqfR86nu_3jFFVXzZQ4NA@mail.gmail.com/
      
      
      Fixes: 024aa580 ("ixgbe: added Rx/Tx ring disable/enable functions")
      Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad91d5d1
    • Oleksij Rempel's avatar
      net: lan78xx: fix runtime PM count underflow on link stop · 336261af
      Oleksij Rempel authored
      
      [ Upstream commit 1eecc7ab ]
      
      Current driver has some asymmetry in the runtime PM calls. On lan78xx_open()
      it will call usb_autopm_get() and unconditionally usb_autopm_put(). And
      on lan78xx_stop() it will call only usb_autopm_put(). So far, it was
      working only because this driver do not activate autosuspend by default,
      so it was visible only by warning "Runtime PM usage count underflow!".
      
      Since, with current driver, we can't use runtime PM with active link,
      execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise,
      keep ref counting high as long as interface is open.
      
      Fixes: 55d7de9d ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      336261af
    • John Efstathiades's avatar
      lan78xx: Fix race conditions in suspend/resume handling · 11a3c9f4
      John Efstathiades authored
      
      [ Upstream commit 5f4cc6e2 ]
      
      If the interface is given an IP address while the device is
      suspended (as a result of an auto-suspend event) there is a race
      between lan78xx_resume() and lan78xx_open() that can result in an
      exception or failure to handle incoming packets. The following
      changes fix this problem.
      
      Introduce a mutex to serialise operations in the network interface
      open and stop entry points with respect to the USB driver suspend
      and resume entry points.
      
      Move Tx and Rx data path start/stop to lan78xx_start() and
      lan78xx_stop() respectively and flush the packet FIFOs before
      starting the Tx and Rx data paths. This prevents the MAC and FIFOs
      getting out of step and delivery of malformed packets to the network
      stack.
      
      Stop processing of received packets before disconnecting the
      PHY from the MAC to prevent a kernel exception caused by handling
      packets after the PHY device has been removed.
      
      Refactor device auto-suspend code to make it consistent with the
      the system suspend code and make the suspend handler easier to read.
      
      Add new code to stop wake-on-lan packets or PHY events resuming the
      host or device from suspend if the device has not been opened
      (typically after an IP address is assigned).
      
      This patch is dependent on changes to lan78xx_suspend() and
      lan78xx_resume() introduced in the previous patch of this patch set.
      
      Signed-off-by: default avatarJohn Efstathiades <john.efstathiades@pebblebay.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 1eecc7ab ("net: lan78xx: fix runtime PM count underflow on link stop")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      11a3c9f4
    • John Efstathiades's avatar
      lan78xx: Fix partial packet errors on suspend/resume · 69215f8e
      John Efstathiades authored
      
      [ Upstream commit e1210fe6 ]
      
      The MAC can get out of step with the internal packet FIFOs if the
      system goes to sleep when the link is active, especially at high
      data rates. This can result in partial frames in the packet FIFOs
      that in result in malformed frames being delivered to the host.
      This occurs because the driver does not enable/disable the internal
      packet FIFOs in step with the corresponding MAC data path. The
      following changes fix this problem.
      
      Update code that enables/disables the MAC receiver and transmitter
      to the more general Rx and Tx data path, where the data path in each
      direction consists of both the MAC function (Tx or Rx) and the
      corresponding packet FIFO.
      
      In the receive path the packet FIFO must be enabled before the MAC
      receiver but disabled after the MAC receiver.
      
      In the transmit path the opposite is true: the packet FIFO must be
      enabled after the MAC transmitter but disabled before the MAC
      transmitter.
      
      The packet FIFOs can be flushed safely once the corresponding data
      path is stopped.
      
      Signed-off-by: default avatarJohn Efstathiades <john.efstathiades@pebblebay.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 1eecc7ab ("net: lan78xx: fix runtime PM count underflow on link stop")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      69215f8e
    • John Efstathiades's avatar
      lan78xx: Add missing return code checks · e5d7f43c
      John Efstathiades authored
      
      [ Upstream commit 3415f6ba ]
      
      There are many places in the driver where the return code from a
      function call is captured but without a subsequent test of the
      return code and appropriate action taken.
      
      This patch adds the missing return code tests and action. In most
      cases the action is an early exit from the calling function.
      
      The function lan78xx_set_suspend() was also updated to make it
      consistent with lan78xx_suspend().
      
      Signed-off-by: default avatarJohn Efstathiades <john.efstathiades@pebblebay.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 1eecc7ab ("net: lan78xx: fix runtime PM count underflow on link stop")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e5d7f43c
    • John Efstathiades's avatar
      lan78xx: Fix white space and style issues · 06133626
      John Efstathiades authored
      
      [ Upstream commit 9ceec7d3 ]
      
      Fix white space and code style issues identified by checkpatch.
      
      Signed-off-by: default avatarJohn Efstathiades <john.efstathiades@pebblebay.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 1eecc7ab ("net: lan78xx: fix runtime PM count underflow on link stop")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      06133626
    • Christophe Kerello's avatar
      mmc: mmci: stm32: fix DMA API overlapping mappings warning · 0224cbc5
      Christophe Kerello authored
      
      [ Upstream commit 6b1ba3f9 ]
      
      Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning:
      
      DMA-API: mmci-pl18x 48220000.mmc: cacheline tracking EEXIST,
      overlapping mappings aren't supported
      WARNING: CPU: 1 PID: 51 at kernel/dma/debug.c:568
      add_dma_entry+0x234/0x2f4
      Modules linked in:
      CPU: 1 PID: 51 Comm: kworker/1:2 Not tainted 6.1.28 #1
      Hardware name: STMicroelectronics STM32MP257F-EV1 Evaluation Board (DT)
      Workqueue: events_freezable mmc_rescan
      Call trace:
      add_dma_entry+0x234/0x2f4
      debug_dma_map_sg+0x198/0x350
      __dma_map_sg_attrs+0xa0/0x110
      dma_map_sg_attrs+0x10/0x2c
      sdmmc_idma_prep_data+0x80/0xc0
      mmci_prep_data+0x38/0x84
      mmci_start_data+0x108/0x2dc
      mmci_request+0xe4/0x190
      __mmc_start_request+0x68/0x140
      mmc_start_request+0x94/0xc0
      mmc_wait_for_req+0x70/0x100
      mmc_send_tuning+0x108/0x1ac
      sdmmc_execute_tuning+0x14c/0x210
      mmc_execute_tuning+0x48/0xec
      mmc_sd_init_uhs_card.part.0+0x208/0x464
      mmc_sd_init_card+0x318/0x89c
      mmc_attach_sd+0xe4/0x180
      mmc_rescan+0x244/0x320
      
      DMA API debug brings to light leaking dma-mappings as dma_map_sg and
      dma_unmap_sg are not correctly balanced.
      
      If an error occurs in mmci_cmd_irq function, only mmci_dma_error
      function is called and as this API is not managed on stm32 variant,
      dma_unmap_sg is never called in this error path.
      
      Signed-off-by: default avatarChristophe Kerello <christophe.kerello@foss.st.com>
      Fixes: 46b723dd ("mmc: mmci: add stm32 sdmmc variant")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20240207143951.938144-1-christophe.kerello@foss.st.com
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0224cbc5
    • Yann Gautier's avatar
      mmc: mmci: stm32: use a buffer for unaligned DMA requests · abda366e
      Yann Gautier authored
      
      [ Upstream commit 970dc9c1 ]
      
      In SDIO mode, the sg list for requests can be unaligned with what the
      STM32 SDMMC internal DMA can support. In that case, instead of failing,
      use a temporary bounce buffer to copy from/to the sg list.
      This buffer is limited to 1MB. But for that we need to also limit
      max_req_size to 1MB. It has not shown any throughput penalties for
      SD-cards or eMMC.
      
      Signed-off-by: default avatarYann Gautier <yann.gautier@foss.st.com>
      Link: https://lore.kernel.org/r/20220328145114.334577-1-yann.gautier@foss.st.com
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Stable-dep-of: 6b1ba3f9 ("mmc: mmci: stm32: fix DMA API overlapping mappings warning")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      abda366e
  2. Mar 06, 2024
    • Greg Kroah-Hartman's avatar
    • Davide Caratti's avatar
      mptcp: fix double-free on socket dismantle · f74362a0
      Davide Caratti authored
      
      commit 10048689 upstream.
      
      when MPTCP server accepts an incoming connection, it clones its listener
      socket. However, the pointer to 'inet_opt' for the new socket has the same
      value as the original one: as a consequence, on program exit it's possible
      to observe the following splat:
      
        BUG: KASAN: double-free in inet_sock_destruct+0x54f/0x8b0
        Free of addr ffff888485950880 by task swapper/25/0
      
        CPU: 25 PID: 0 Comm: swapper/25 Kdump: loaded Not tainted 6.8.0-rc1+ #609
        Hardware name: Supermicro SYS-6027R-72RF/X9DRH-7TF/7F/iTF/iF, BIOS 3.0  07/26/2013
        Call Trace:
         <IRQ>
         dump_stack_lvl+0x32/0x50
         print_report+0xca/0x620
         kasan_report_invalid_free+0x64/0x90
         __kasan_slab_free+0x1aa/0x1f0
         kfree+0xed/0x2e0
         inet_sock_destruct+0x54f/0x8b0
         __sk_destruct+0x48/0x5b0
         rcu_do_batch+0x34e/0xd90
         rcu_core+0x559/0xac0
         __do_softirq+0x183/0x5a4
         irq_exit_rcu+0x12d/0x170
         sysvec_apic_timer_interrupt+0x6b/0x80
         </IRQ>
         <TASK>
         asm_sysvec_apic_timer_interrupt+0x16/0x20
        RIP: 0010:cpuidle_enter_state+0x175/0x300
        Code: 30 00 0f 84 1f 01 00 00 83 e8 01 83 f8 ff 75 e5 48 83 c4 18 44 89 e8 5b 5d 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc fb 45 85 ed <0f> 89 60 ff ff ff 48 c1 e5 06 48 c7 43 18 00 00 00 00 48 83 44 2b
        RSP: 0018:ffff888481cf7d90 EFLAGS: 00000202
        RAX: 0000000000000000 RBX: ffff88887facddc8 RCX: 0000000000000000
        RDX: 1ffff1110ff588b1 RSI: 0000000000000019 RDI: ffff88887fac4588
        RBP: 0000000000000004 R08: 0000000000000002 R09: 0000000000043080
        R10: 0009b02ea273363f R11: ffff88887fabf42b R12: ffffffff932592e0
        R13: 0000000000000004 R14: 0000000000000000 R15: 00000022c880ec80
         cpuidle_enter+0x4a/0xa0
         do_idle+0x310/0x410
         cpu_startup_entry+0x51/0x60
         start_secondary+0x211/0x270
         secondary_startup_64_no_verify+0x184/0x18b
         </TASK>
      
        Allocated by task 6853:
         kasan_save_stack+0x1c/0x40
         kasan_save_track+0x10/0x30
         __kasan_kmalloc+0xa6/0xb0
         __kmalloc+0x1eb/0x450
         cipso_v4_sock_setattr+0x96/0x360
         netlbl_sock_setattr+0x132/0x1f0
         selinux_netlbl_socket_post_create+0x6c/0x110
         selinux_socket_post_create+0x37b/0x7f0
         security_socket_post_create+0x63/0xb0
         __sock_create+0x305/0x450
         __sys_socket_create.part.23+0xbd/0x130
         __sys_socket+0x37/0xb0
         __x64_sys_socket+0x6f/0xb0
         do_syscall_64+0x83/0x160
         entry_SYSCALL_64_after_hwframe+0x6e/0x76
      
        Freed by task 6858:
         kasan_save_stack+0x1c/0x40
         kasan_save_track+0x10/0x30
         kasan_save_free_info+0x3b/0x60
         __kasan_slab_free+0x12c/0x1f0
         kfree+0xed/0x2e0
         inet_sock_destruct+0x54f/0x8b0
         __sk_destruct+0x48/0x5b0
         subflow_ulp_release+0x1f0/0x250
         tcp_cleanup_ulp+0x6e/0x110
         tcp_v4_destroy_sock+0x5a/0x3a0
         inet_csk_destroy_sock+0x135/0x390
         tcp_fin+0x416/0x5c0
         tcp_data_queue+0x1bc8/0x4310
         tcp_rcv_state_process+0x15a3/0x47b0
         tcp_v4_do_rcv+0x2c1/0x990
         tcp_v4_rcv+0x41fb/0x5ed0
         ip_protocol_deliver_rcu+0x6d/0x9f0
         ip_local_deliver_finish+0x278/0x360
         ip_local_deliver+0x182/0x2c0
         ip_rcv+0xb5/0x1c0
         __netif_receive_skb_one_core+0x16e/0x1b0
         process_backlog+0x1e3/0x650
         __napi_poll+0xa6/0x500
         net_rx_action+0x740/0xbb0
         __do_softirq+0x183/0x5a4
      
        The buggy address belongs to the object at ffff888485950880
         which belongs to the cache kmalloc-64 of size 64
        The buggy address is located 0 bytes inside of
         64-byte region [ffff888485950880, ffff8884859508c0)
      
        The buggy address belongs to the physical page:
        page:0000000056d1e95e refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888485950700 pfn:0x485950
        flags: 0x57ffffc0000800(slab|node=1|zone=2|lastcpupid=0x1fffff)
        page_type: 0xffffffff()
        raw: 0057ffffc0000800 ffff88810004c640 ffffea00121b8ac0 dead000000000006
        raw: ffff888485950700 0000000000200019 00000001ffffffff 0000000000000000
        page dumped because: kasan: bad access detected
      
        Memory state around the buggy address:
         ffff888485950780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
         ffff888485950800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
        >ffff888485950880: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                           ^
         ffff888485950900: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
         ffff888485950980: 00 00 00 00 00 01 fc fc fc fc fc fc fc fc fc fc
      
      Something similar (a refcount underflow) happens with CALIPSO/IPv6. Fix
      this by duplicating IP / IPv6 options after clone, so that
      ip{,6}_sock_destruct() doesn't end up freeing the same memory area twice.
      
      Fixes: cf7da0d6 ("mptcp: Create SUBFLOW socket for incoming connections")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
      Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-8-162e87e48497@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f74362a0
    • Chuanhong Guo's avatar
      mtd: spinand: gigadevice: fix Quad IO for GD5F1GQ5UExxG · 30d84d87
      Chuanhong Guo authored
      commit a4f9dd55 upstream.
      
      Read From Cache Quad IO (EBH) uses 2 dummy bytes on this chip according
      to page 23 of the datasheet[0].
      
      [0]: https://www.gigadevice.com/datasheet/gd5f1gq5xexxg/
      
      
      
      Fixes: 469b9924 ("mtd: spinand: gigadevice: Support GD5F1GQ5UExxG")
      Signed-off-by: default avatarChuanhong Guo <gch981213@gmail.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20220320100001.247905-2-gch981213@gmail.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30d84d87
    • Bartosz Golaszewski's avatar
      gpio: fix resource unwinding order in error path · 1805131d
      Bartosz Golaszewski authored
      
      [ Upstream commit ec5c54a9 ]
      
      Hogs are added *after* ACPI so should be removed *before* in error path.
      
      Fixes: a411e81e ("gpiolib: add hogs support for machine code")
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1805131d
    • Andy Shevchenko's avatar
      gpiolib: Fix the error path order in gpiochip_add_data_with_key() · 51f7044d
      Andy Shevchenko authored
      
      [ Upstream commit e4aec4da ]
      
      After shuffling the code, error path wasn't updated correctly.
      Fix it here.
      
      Fixes: 2f4133bb ("gpiolib: No need to call gpiochip_remove_pin_ranges() twice")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51f7044d
    • Arturas Moskvinas's avatar
      gpio: 74x164: Enable output pins after registers are reset · 947baae1
      Arturas Moskvinas authored
      [ Upstream commit 530b1dbd ]
      
      Chip outputs are enabled[1] before actual reset is performed[2] which might
      cause pin output value to flip flop if previous pin value was set to 1.
      Fix that behavior by making sure chip is fully reset before all outputs are
      enabled.
      
      Flip-flop can be noticed when module is removed and inserted again and one of
      the pins was changed to 1 before removal. 100 microsecond flipping is
      noticeable on oscilloscope (100khz SPI bus).
      
      For a properly reset chip - output is enabled around 100 microseconds (on 100khz
      SPI bus) later during probing process hence should be irrelevant behavioral
      change.
      
      Fixes: 7ebc194d (gpio: 74x164: Introduce 'enable-gpios' property)
      Link: https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130 [1]
      Link: https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150
      
       [2]
      Signed-off-by: default avatarArturas Moskvinas <arturas.moskvinas@gmail.com>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      947baae1
    • Oscar Salvador's avatar
      fs,hugetlb: fix NULL pointer dereference in hugetlbs_fill_super · 80d85229
      Oscar Salvador authored
      commit 79d72c68 upstream.
      
      When configuring a hugetlb filesystem via the fsconfig() syscall, there is
      a possible NULL dereference in hugetlbfs_fill_super() caused by assigning
      NULL to ctx->hstate in hugetlbfs_parse_param() when the requested pagesize
      is non valid.
      
      E.g: Taking the following steps:
      
           fd = fsopen("hugetlbfs", FSOPEN_CLOEXEC);
           fsconfig(fd, FSCONFIG_SET_STRING, "pagesize", "1024", 0);
           fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0);
      
      Given that the requested "pagesize" is invalid, ctxt->hstate will be replaced
      with NULL, losing its previous value, and we will print an error:
      
       ...
       ...
       case Opt_pagesize:
       ps = memparse(param->string, &rest);
       ctx->hstate = h;
       if (!ctx->hstate) {
               pr_err("Unsupported page size %lu MB\n", ps / SZ_1M);
               return -EINVAL;
       }
       return 0;
       ...
       ...
      
      This is a problem because later on, we will dereference ctxt->hstate in
      hugetlbfs_fill_super()
      
       ...
       ...
       sb->s_blocksize = huge_page_size(ctx->hstate);
       ...
       ...
      
      Causing below Oops.
      
      Fix this by replacing cxt->hstate value only when then pagesize is known
      to be valid.
      
       kernel: hugetlbfs: Unsupported page size 0 MB
       kernel: BUG: kernel NULL pointer dereference, address: 0000000000000028
       kernel: #PF: supervisor read access in kernel mode
       kernel: #PF: error_code(0x0000) - not-present page
       kernel: PGD 800000010f66c067 P4D 800000010f66c067 PUD 1b22f8067 PMD 0
       kernel: Oops: 0000 [#1] PREEMPT SMP PTI
       kernel: CPU: 4 PID: 5659 Comm: syscall Tainted: G            E      6.8.0-rc2-default+ #22 5a47c3fef76212addcc6eb71344aabc35190ae8f
       kernel: Hardware name: Intel Corp. GROVEPORT/GROVEPORT, BIOS GVPRCRB1.86B.0016.D04.1705030402 05/03/2017
       kernel: RIP: 0010:hugetlbfs_fill_super+0xb4/0x1a0
       kernel: Code: 48 8b 3b e8 3e c6 ed ff 48 85 c0 48 89 45 20 0f 84 d6 00 00 00 48 b8 ff ff ff ff ff ff ff 7f 4c 89 e7 49 89 44 24 20 48 8b 03 <8b> 48 28 b8 00 10 00 00 48 d3 e0 49 89 44 24 18 48 8b 03 8b 40 28
       kernel: RSP: 0018:ffffbe9960fcbd48 EFLAGS: 00010246
       kernel: RAX: 0000000000000000 RBX: ffff9af5272ae780 RCX: 0000000000372004
       kernel: RDX: ffffffffffffffff RSI: ffffffffffffffff RDI: ffff9af555e9b000
       kernel: RBP: ffff9af52ee66b00 R08: 0000000000000040 R09: 0000000000370004
       kernel: R10: ffffbe9960fcbd48 R11: 0000000000000040 R12: ffff9af555e9b000
       kernel: R13: ffffffffa66b86c0 R14: ffff9af507d2f400 R15: ffff9af507d2f400
       kernel: FS:  00007ffbc0ba4740(0000) GS:ffff9b0bd7000000(0000) knlGS:0000000000000000
       kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       kernel: CR2: 0000000000000028 CR3: 00000001b1ee0000 CR4: 00000000001506f0
       kernel: Call Trace:
       kernel:  <TASK>
       kernel:  ? __die_body+0x1a/0x60
       kernel:  ? page_fault_oops+0x16f/0x4a0
       kernel:  ? search_bpf_extables+0x65/0x70
       kernel:  ? fixup_exception+0x22/0x310
       kernel:  ? exc_page_fault+0x69/0x150
       kernel:  ? asm_exc_page_fault+0x22/0x30
       kernel:  ? __pfx_hugetlbfs_fill_super+0x10/0x10
       kernel:  ? hugetlbfs_fill_super+0xb4/0x1a0
       kernel:  ? hugetlbfs_fill_super+0x28/0x1a0
       kernel:  ? __pfx_hugetlbfs_fill_super+0x10/0x10
       kernel:  vfs_get_super+0x40/0xa0
       kernel:  ? __pfx_bpf_lsm_capable+0x10/0x10
       kernel:  vfs_get_tree+0x25/0xd0
       kernel:  vfs_cmd_create+0x64/0xe0
       kernel:  __x64_sys_fsconfig+0x395/0x410
       kernel:  do_syscall_64+0x80/0x160
       kernel:  ? syscall_exit_to_user_mode+0x82/0x240
       kernel:  ? do_syscall_64+0x8d/0x160
       kernel:  ? syscall_exit_to_user_mode+0x82/0x240
       kernel:  ? do_syscall_64+0x8d/0x160
       kernel:  ? exc_page_fault+0x69/0x150
       kernel:  entry_SYSCALL_64_after_hwframe+0x6e/0x76
       kernel: RIP: 0033:0x7ffbc0cb87c9
       kernel: Code: 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 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 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 97 96 0d 00 f7 d8 64 89 01 48
       kernel: RSP: 002b:00007ffc29d2f388 EFLAGS: 00000206 ORIG_RAX: 00000000000001af
       kernel: RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ffbc0cb87c9
       kernel: RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000003
       kernel: RBP: 00007ffc29d2f3b0 R08: 0000000000000000 R09: 0000000000000000
       kernel: R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
       kernel: R13: 00007ffc29d2f4c0 R14: 0000000000000000 R15: 0000000000000000
       kernel:  </TASK>
       kernel: Modules linked in: rpcsec_gss_krb5(E) auth_rpcgss(E) nfsv4(E) dns_resolver(E) nfs(E) lockd(E) grace(E) sunrpc(E) netfs(E) af_packet(E) bridge(E) stp(E) llc(E) iscsi_ibft(E) iscsi_boot_sysfs(E) intel_rapl_msr(E) intel_rapl_common(E) iTCO_wdt(E) intel_pmc_bxt(E) sb_edac(E) iTCO_vendor_support(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) coretemp(E) kvm_intel(E) rfkill(E) ipmi_ssif(E) kvm(E) acpi_ipmi(E) irqbypass(E) pcspkr(E) igb(E) ipmi_si(E) mei_me(E) i2c_i801(E) joydev(E) intel_pch_thermal(E) i2c_smbus(E) dca(E) lpc_ich(E) mei(E) ipmi_devintf(E) ipmi_msghandler(E) acpi_pad(E) tiny_power_button(E) button(E) fuse(E) efi_pstore(E) configfs(E) ip_tables(E) x_tables(E) ext4(E) mbcache(E) jbd2(E) hid_generic(E) usbhid(E) sd_mod(E) t10_pi(E) crct10dif_pclmul(E) crc32_pclmul(E) crc32c_intel(E) polyval_clmulni(E) ahci(E) xhci_pci(E) polyval_generic(E) gf128mul(E) ghash_clmulni_intel(E) sha512_ssse3(E) sha256_ssse3(E) xhci_pci_renesas(E) libahci(E) ehci_pci(E) sha1_ssse3(E) xhci_hcd(E) ehci_hcd(E) libata(E)
       kernel:  mgag200(E) i2c_algo_bit(E) usbcore(E) wmi(E) sg(E) dm_multipath(E) dm_mod(E) scsi_dh_rdac(E) scsi_dh_emc(E) scsi_dh_alua(E) scsi_mod(E) scsi_common(E) aesni_intel(E) crypto_simd(E) cryptd(E)
       kernel: Unloaded tainted modules: acpi_cpufreq(E):1 fjes(E):1
       kernel: CR2: 0000000000000028
       kernel: ---[ end trace 0000000000000000 ]---
       kernel: RIP: 0010:hugetlbfs_fill_super+0xb4/0x1a0
       kernel: Code: 48 8b 3b e8 3e c6 ed ff 48 85 c0 48 89 45 20 0f 84 d6 00 00 00 48 b8 ff ff ff ff ff ff ff 7f 4c 89 e7 49 89 44 24 20 48 8b 03 <8b> 48 28 b8 00 10 00 00 48 d3 e0 49 89 44 24 18 48 8b 03 8b 40 28
       kernel: RSP: 0018:ffffbe9960fcbd48 EFLAGS: 00010246
       kernel: RAX: 0000000000000000 RBX: ffff9af5272ae780 RCX: 0000000000372004
       kernel: RDX: ffffffffffffffff RSI: ffffffffffffffff RDI: ffff9af555e9b000
       kernel: RBP: ffff9af52ee66b00 R08: 0000000000000040 R09: 0000000000370004
       kernel: R10: ffffbe9960fcbd48 R11: 0000000000000040 R12: ffff9af555e9b000
       kernel: R13: ffffffffa66b86c0 R14: ffff9af507d2f400 R15: ffff9af507d2f400
       kernel: FS:  00007ffbc0ba4740(0000) GS:ffff9b0bd7000000(0000) knlGS:0000000000000000
       kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       kernel: CR2: 0000000000000028 CR3: 00000001b1ee0000 CR4: 00000000001506f0
      
      Link: https://lkml.kernel.org/r/20240130210418.3771-1-osalvador@suse.de
      
      
      Fixes: 32021982 ("hugetlbfs: Convert to fs_context")
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Acked-by: default avatarMuchun Song <muchun.song@linux.dev>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarVamsi Krishna Brahmajosyula <vamsi-krishna.brahmajosyula@broadcom.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80d85229
    • Baokun Li's avatar
      cachefiles: fix memory leak in cachefiles_add_cache() · 43eccc58
      Baokun Li authored
      
      commit e21a2f17 upstream.
      
      The following memory leak was reported after unbinding /dev/cachefiles:
      
      ==================================================================
      unreferenced object 0xffff9b674176e3c0 (size 192):
        comm "cachefilesd2", pid 680, jiffies 4294881224
        hex dump (first 32 bytes):
          01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace (crc ea38a44b):
          [<ffffffff8eb8a1a5>] kmem_cache_alloc+0x2d5/0x370
          [<ffffffff8e917f86>] prepare_creds+0x26/0x2e0
          [<ffffffffc002eeef>] cachefiles_determine_cache_security+0x1f/0x120
          [<ffffffffc00243ec>] cachefiles_add_cache+0x13c/0x3a0
          [<ffffffffc0025216>] cachefiles_daemon_write+0x146/0x1c0
          [<ffffffff8ebc4a3b>] vfs_write+0xcb/0x520
          [<ffffffff8ebc5069>] ksys_write+0x69/0xf0
          [<ffffffff8f6d4662>] do_syscall_64+0x72/0x140
          [<ffffffff8f8000aa>] entry_SYSCALL_64_after_hwframe+0x6e/0x76
      ==================================================================
      
      Put the reference count of cache_cred in cachefiles_daemon_unbind() to
      fix the problem. And also put cache_cred in cachefiles_add_cache() error
      branch to avoid memory leaks.
      
      Fixes: 9ae326a6 ("CacheFiles: A cache that backs onto a mounted filesystem")
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Link: https://lore.kernel.org/r/20240217081431.796809-1-libaokun1@huawei.com
      
      
      Acked-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarJingbo Xu <jefflexu@linux.alibaba.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43eccc58
    • Baokun Li's avatar
      ext4: avoid bb_free and bb_fragments inconsistency in mb_free_blocks() · 28717281
      Baokun Li authored
      
      commit 2331fd4a upstream.
      
      After updating bb_free in mb_free_blocks, it is possible to return without
      updating bb_fragments because the block being freed is found to have
      already been freed, which leads to inconsistency between bb_free and
      bb_fragments.
      
      Since the group may be unlocked in ext4_grp_locked_error(), this can lead
      to problems such as dividing by zero when calculating the average fragment
      length. Hence move the update of bb_free to after the block double-free
      check guarantees that the corresponding statistics are updated only after
      the core block bitmap is modified.
      
      Fixes: eabe0444 ("ext4: speed-up releasing blocks on commit")
      CC:  <stable@vger.kernel.org> # 3.10
      Suggested-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20240104142040.2835097-5-libaokun1@huawei.com
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28717281
    • Paolo Abeni's avatar
      mptcp: fix possible deadlock in subflow diag · 70e5b013
      Paolo Abeni authored
      
      commit d6a9608a upstream.
      
      Syzbot and Eric reported a lockdep splat in the subflow diag:
      
         WARNING: possible circular locking dependency detected
         6.8.0-rc4-syzkaller-00212-g40b9385dd8e6 #0 Not tainted
      
         syz-executor.2/24141 is trying to acquire lock:
         ffff888045870130 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at:
         tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
         ffff888045870130 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at:
         tcp_diag_get_aux+0x738/0x830 net/ipv4/tcp_diag.c:137
      
         but task is already holding lock:
         ffffc9000135e488 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock
         include/linux/spinlock.h:351 [inline]
         ffffc9000135e488 (&h->lhash2[i].lock){+.+.}-{2:2}, at:
         inet_diag_dump_icsk+0x39f/0x1f80 net/ipv4/inet_diag.c:1038
      
         which lock already depends on the new lock.
      
         the existing dependency chain (in reverse order) is:
      
         -> #1 (&h->lhash2[i].lock){+.+.}-{2:2}:
         lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
         __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
         _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
         spin_lock include/linux/spinlock.h:351 [inline]
         __inet_hash+0x335/0xbe0 net/ipv4/inet_hashtables.c:743
         inet_csk_listen_start+0x23a/0x320 net/ipv4/inet_connection_sock.c:1261
         __inet_listen_sk+0x2a2/0x770 net/ipv4/af_inet.c:217
         inet_listen+0xa3/0x110 net/ipv4/af_inet.c:239
         rds_tcp_listen_init+0x3fd/0x5a0 net/rds/tcp_listen.c:316
         rds_tcp_init_net+0x141/0x320 net/rds/tcp.c:577
         ops_init+0x352/0x610 net/core/net_namespace.c:136
         __register_pernet_operations net/core/net_namespace.c:1214 [inline]
         register_pernet_operations+0x2cb/0x660 net/core/net_namespace.c:1283
         register_pernet_device+0x33/0x80 net/core/net_namespace.c:1370
         rds_tcp_init+0x62/0xd0 net/rds/tcp.c:735
         do_one_initcall+0x238/0x830 init/main.c:1236
         do_initcall_level+0x157/0x210 init/main.c:1298
         do_initcalls+0x3f/0x80 init/main.c:1314
         kernel_init_freeable+0x42f/0x5d0 init/main.c:1551
         kernel_init+0x1d/0x2a0 init/main.c:1441
         ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
         ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
      
         -> #0 (k-sk_lock-AF_INET6){+.+.}-{0:0}:
         check_prev_add kernel/locking/lockdep.c:3134 [inline]
         check_prevs_add kernel/locking/lockdep.c:3253 [inline]
         validate_chain+0x18ca/0x58e0 kernel/locking/lockdep.c:3869
         __lock_acquire+0x1345/0x1fd0 kernel/locking/lockdep.c:5137
         lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
         lock_sock_fast include/net/sock.h:1723 [inline]
         subflow_get_info+0x166/0xd20 net/mptcp/diag.c:28
         tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
         tcp_diag_get_aux+0x738/0x830 net/ipv4/tcp_diag.c:137
         inet_sk_diag_fill+0x10ed/0x1e00 net/ipv4/inet_diag.c:345
         inet_diag_dump_icsk+0x55b/0x1f80 net/ipv4/inet_diag.c:1061
         __inet_diag_dump+0x211/0x3a0 net/ipv4/inet_diag.c:1263
         inet_diag_dump_compat+0x1c1/0x2d0 net/ipv4/inet_diag.c:1371
         netlink_dump+0x59b/0xc80 net/netlink/af_netlink.c:2264
         __netlink_dump_start+0x5df/0x790 net/netlink/af_netlink.c:2370
         netlink_dump_start include/linux/netlink.h:338 [inline]
         inet_diag_rcv_msg_compat+0x209/0x4c0 net/ipv4/inet_diag.c:1405
         sock_diag_rcv_msg+0xe7/0x410
         netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
         sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280
         netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
         netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
         netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
         sock_sendmsg_nosec net/socket.c:730 [inline]
         __sock_sendmsg+0x221/0x270 net/socket.c:745
         ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
         ___sys_sendmsg net/socket.c:2638 [inline]
         __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
         do_syscall_64+0xf9/0x240
         entry_SYSCALL_64_after_hwframe+0x6f/0x77
      
      As noted by Eric we can break the lock dependency chain avoid
      dumping any extended info for the mptcp subflow listener:
      nothing actually useful is presented there.
      
      Fixes: b8adb69a ("mptcp: fix lockless access in subflow ULP diag")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarEric Dumazet <edumazet@google.com>
      Closes: https://lore.kernel.org/netdev/CANn89iJ=Oecw6OZDwmSYc9HJKQ_G32uN11L+oUcMu+TOD5Xiaw@mail.gmail.com/
      
      
      Suggested-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-9-162e87e48497@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70e5b013
    • Paolo Bonzini's avatar
      x86/cpu/intel: Detect TME keyid bits before setting MTRR mask registers · 36103f8c
      Paolo Bonzini authored
      
      commit 6890cb1a upstream.
      
      MKTME repurposes the high bit of physical address to key id for encryption
      key and, even though MAXPHYADDR in CPUID[0x80000008] remains the same,
      the valid bits in the MTRR mask register are based on the reduced number
      of physical address bits.
      
      detect_tme() in arch/x86/kernel/cpu/intel.c detects TME and subtracts
      it from the total usable physical bits, but it is called too late.
      Move the call to early_init_intel() so that it is called in setup_arch(),
      before MTRRs are setup.
      
      This fixes boot on TDX-enabled systems, which until now only worked with
      "disable_mtrr_cleanup".  Without the patch, the values written to the
      MTRRs mask registers were 52-bit wide (e.g. 0x000fffff_80000800) and
      the writes failed; with the patch, the values are 46-bit wide, which
      matches the reduced MAXPHYADDR that is shown in /proc/cpuinfo.
      
      Reported-by: default avatarZixi Chen <zixchen@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Cc:stable@vger.kernel.org
      Link: https://lore.kernel.org/all/20240131230902.1867092-3-pbonzini%40redhat.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36103f8c
    • Bjorn Andersson's avatar
      pmdomain: qcom: rpmhpd: Fix enabled_corner aggregation · 7a7cb526
      Bjorn Andersson authored
      
      commit 2a93c6cb upstream.
      
      Commit 'e3e56c05 ("soc: qcom: rpmhpd: Make power_on actually enable
      the domain")' aimed to make sure that a power-domain that is being
      enabled without any particular performance-state requested will at least
      turn the rail on, to avoid filling DeviceTree with otherwise unnecessary
      required-opps properties.
      
      But in the event that aggregation happens on a disabled power-domain, with
      an enabled peer without performance-state, both the local and peer
      corner are 0. The peer's enabled_corner is not considered, with the
      result that the underlying (shared) resource is disabled.
      
      One case where this can be observed is when the display stack keeps mmcx
      enabled (but without a particular performance-state vote) in order to
      access registers and sync_state happens in the rpmhpd driver. As mmcx_ao
      is flushed the state of the peer (mmcx) is not considered and mmcx_ao
      ends up turning off "mmcx.lvl" underneath mmcx. This has been observed
      several times, but has been painted over in DeviceTree by adding an
      explicit vote for the lowest non-disabled performance-state.
      
      Fixes: e3e56c05 ("soc: qcom: rpmhpd: Make power_on actually enable the domain")
      Reported-by: default avatarJohan Hovold <johan@kernel.org>
      Closes: https://lore.kernel.org/linux-arm-msm/ZdMwZa98L23mu3u6@hovoldconsulting.com/
      
      
      Cc:  <stable@vger.kernel.org>
      Signed-off-by: default avatarBjorn Andersson <quic_bjorande@quicinc.com>
      Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Tested-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Tested-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20240226-rpmhpd-enable-corner-fix-v1-1-68c004cec48c@quicinc.com
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7a7cb526
    • Elad Nachman's avatar
      mmc: sdhci-xenon: fix PHY init clock stability · 36b02df0
      Elad Nachman authored
      
      commit 8e9f25a2 upstream.
      
      Each time SD/mmc phy is initialized, at times, in some of
      the attempts, phy fails to completes its initialization
      which results into timeout error. Per the HW spec, it is
      a pre-requisite to ensure a stable SD clock before a phy
      initialization is attempted.
      
      Fixes: 06c8b667 ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC")
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarElad Nachman <enachman@marvell.com>
      Link: https://lore.kernel.org/r/20240222200930.1277665-1-enachman@marvell.com
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36b02df0
    • Elad Nachman's avatar
      mmc: sdhci-xenon: add timeout for PHY init complete · d3c703c2
      Elad Nachman authored
      
      commit 09e23823 upstream.
      
      AC5X spec says PHY init complete bit must be polled until zero.
      We see cases in which timeout can take longer than the standard
      calculation on AC5X, which is expected following the spec comment above.
      According to the spec, we must wait as long as it takes for that bit to
      toggle on AC5X.
      Cap that with 100 delay loops so we won't get stuck forever.
      
      Fixes: 06c8b667 ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC")
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarElad Nachman <enachman@marvell.com>
      Link: https://lore.kernel.org/r/20240222191714.1216470-3-enachman@marvell.com
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3c703c2
    • Ivan Semenov's avatar
      mmc: core: Fix eMMC initialization with 1-bit bus connection · 3fd14520
      Ivan Semenov authored
      
      commit ff3206d2 upstream.
      
      Initializing an eMMC that's connected via a 1-bit bus is current failing,
      if the HW (DT) informs that 4-bit bus is supported. In fact this is a
      regression, as we were earlier capable of falling back to 1-bit mode, when
      switching to 4/8-bit bus failed. Therefore, let's restore the behaviour.
      
      Log for Samsung eMMC 5.1 chip connected via 1bit bus (only D0 pin)
      Before patch:
      [134509.044225] mmc0: switch to bus width 4 failed
      [134509.044509] mmc0: new high speed MMC card at address 0001
      [134509.054594] mmcblk0: mmc0:0001 BGUF4R 29.1 GiB
      [134509.281602] mmc0: switch to bus width 4 failed
      [134509.282638] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.282657] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.284598] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.284602] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.284609] ldm_validate_partition_table(): Disk read failed.
      [134509.286495] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.286500] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.288303] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.288308] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.289540] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.289544] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.289553]  mmcblk0: unable to read partition table
      [134509.289728] mmcblk0boot0: mmc0:0001 BGUF4R 31.9 MiB
      [134509.290283] mmcblk0boot1: mmc0:0001 BGUF4R 31.9 MiB
      [134509.294577] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
      [134509.295835] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.295841] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      
      After patch:
      
      [134551.089613] mmc0: switch to bus width 4 failed
      [134551.090377] mmc0: new high speed MMC card at address 0001
      [134551.102271] mmcblk0: mmc0:0001 BGUF4R 29.1 GiB
      [134551.113365]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21
      [134551.114262] mmcblk0boot0: mmc0:0001 BGUF4R 31.9 MiB
      [134551.114925] mmcblk0boot1: mmc0:0001 BGUF4R 31.9 MiB
      
      Fixes: 577fb131 ("mmc: rework selection of bus speed mode")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarIvan Semenov <ivan@semenov.dev>
      Link: https://lore.kernel.org/r/20240206172845.34316-1-ivan@semenov.dev
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fd14520
    • Curtis Klein's avatar
      dmaengine: fsl-qdma: init irq after reg initialization · 9579a21e
      Curtis Klein authored
      
      commit 87a39071 upstream.
      
      Initialize the qDMA irqs after the registers are configured so that
      interrupts that may have been pending from a primary kernel don't get
      processed by the irq handler before it is ready to and cause panic with
      the following trace:
      
        Call trace:
         fsl_qdma_queue_handler+0xf8/0x3e8
         __handle_irq_event_percpu+0x78/0x2b0
         handle_irq_event_percpu+0x1c/0x68
         handle_irq_event+0x44/0x78
         handle_fasteoi_irq+0xc8/0x178
         generic_handle_irq+0x24/0x38
         __handle_domain_irq+0x90/0x100
         gic_handle_irq+0x5c/0xb8
         el1_irq+0xb8/0x180
         _raw_spin_unlock_irqrestore+0x14/0x40
         __setup_irq+0x4bc/0x798
         request_threaded_irq+0xd8/0x190
         devm_request_threaded_irq+0x74/0xe8
         fsl_qdma_probe+0x4d4/0xca8
         platform_drv_probe+0x50/0xa0
         really_probe+0xe0/0x3f8
         driver_probe_device+0x64/0x130
         device_driver_attach+0x6c/0x78
         __driver_attach+0xbc/0x158
         bus_for_each_dev+0x5c/0x98
         driver_attach+0x20/0x28
         bus_add_driver+0x158/0x220
         driver_register+0x60/0x110
         __platform_driver_register+0x44/0x50
         fsl_qdma_driver_init+0x18/0x20
         do_one_initcall+0x48/0x258
         kernel_init_freeable+0x1a4/0x23c
         kernel_init+0x10/0xf8
         ret_from_fork+0x10/0x18
      
      Cc: stable@vger.kernel.org
      Fixes: b092529e ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
      Signed-off-by: default avatarCurtis Klein <curtis.klein@hpe.com>
      Signed-off-by: default avatarYi Zhao <yi.zhao@nxp.com>
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Link: https://lore.kernel.org/r/20240201220406.440145-1-Frank.Li@nxp.com
      
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9579a21e
    • Peng Ma's avatar
      dmaengine: fsl-qdma: fix SoC may hang on 16 byte unaligned read · bb3a06e9
      Peng Ma authored
      
      commit 9d739bcc upstream.
      
      There is chip (ls1028a) errata:
      
      The SoC may hang on 16 byte unaligned read transactions by QDMA.
      
      Unaligned read transactions initiated by QDMA may stall in the NOC
      (Network On-Chip), causing a deadlock condition. Stalled transactions will
      trigger completion timeouts in PCIe controller.
      
      Workaround:
      Enable prefetch by setting the source descriptor prefetchable bit
      ( SD[PF] = 1 ).
      
      Implement this workaround.
      
      Cc: stable@vger.kernel.org
      Fixes: b092529e ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
      Signed-off-by: default avatarPeng Ma <peng.ma@nxp.com>
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Link: https://lore.kernel.org/r/20240201215007.439503-1-Frank.Li@nxp.com
      
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb3a06e9
Loading