Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Apr 05, 2023
    • Greg Kroah-Hartman's avatar
    • Andreas Gruenbacher's avatar
      gfs2: Always check inode size of inline inodes · 4d4cb766
      Andreas Gruenbacher authored
      commit 70376c7f
      
       upstream.
      
      Check if the inode size of stuffed (inline) inodes is within the allowed
      range when reading inodes from disk (gfs2_dinode_in()).  This prevents
      us from on-disk corruption.
      
      The two checks in stuffed_readpage() and gfs2_unstuffer_page() that just
      truncate inline data to the maximum allowed size don't actually make
      sense, and they can be removed now as well.
      
      Reported-by: default avatar <syzbot+7bb81dfa9cda07d9cd9d@syzkaller.appspotmail.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      [pchelkin@ispras.ru: adjust the inode variable inside gfs2_dinode_in with
      the format used before upstream commit 7db35444
      
       ("gfs2: Cosmetic
      gfs2_dinode_{in,out} cleanup")]
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d4cb766
    • Cristian Marussi's avatar
      firmware: arm_scmi: Fix device node validation for mailbox transport · 928240c3
      Cristian Marussi authored
      commit 2ab4f401 upstream.
      
      When mailboxes are used as a transport it is possible to setup the SCMI
      transport layer, depending on the underlying channels configuration, to use
      one or two mailboxes, associated, respectively, to one or two, distinct,
      shared memory areas: any other combination should be treated as invalid.
      
      Add more strict checking of SCMI mailbox transport device node descriptors.
      
      Fixes: 5c8a47a5
      
       ("firmware: arm_scmi: Make scmi core independent of the transport type")
      Cc: <stable@vger.kernel.org> # 4.19
      Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Link: https://lore.kernel.org/r/20230307162324.891866-1-cristian.marussi@arm.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      [Cristian: backported to v5.4]
      Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      928240c3
    • Eric Dumazet's avatar
      net: sched: fix race condition in qdisc_graft() · 0f5c0e0a
      Eric Dumazet authored
      commit ebda44da upstream.
      
      We had one syzbot report [1] in syzbot queue for a while.
      I was waiting for more occurrences and/or a repro but
      Dmitry Vyukov spotted the issue right away.
      
      <quoting Dmitry>
      qdisc_graft() drops reference to qdisc in notify_and_destroy
      while it's still assigned to dev->qdisc
      </quoting>
      
      Indeed, RCU rules are clear when replacing a data structure.
      The visible pointer (dev->qdisc in this case) must be updated
      to the new object _before_ RCU grace period is started
      (qdisc_put(old) in this case).
      
      [1]
      BUG: KASAN: use-after-free in __tcf_qdisc_find.part.0+0xa3a/0xac0 net/sched/cls_api.c:1066
      Read of size 4 at addr ffff88802065e038 by task syz-executor.4/21027
      
      CPU: 0 PID: 21027 Comm: syz-executor.4 Not tainted 6.0.0-rc3-syzkaller-00363-g7726d4c3e60b #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
      print_address_description mm/kasan/report.c:317 [inline]
      print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
      kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
      __tcf_qdisc_find.part.0+0xa3a/0xac0 net/sched/cls_api.c:1066
      __tcf_qdisc_find net/sched/cls_api.c:1051 [inline]
      tc_new_tfilter+0x34f/0x2200 net/sched/cls_api.c:2018
      rtnetlink_rcv_msg+0x955/0xca0 net/core/rtnetlink.c:6081
      netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
      netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
      netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
      netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
      sock_sendmsg_nosec net/socket.c:714 [inline]
      sock_sendmsg+0xcf/0x120 net/socket.c:734
      ____sys_sendmsg+0x6eb/0x810 net/socket.c:2482
      ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
      __sys_sendmsg+0xf3/0x1c0 net/socket.c:2565
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f5efaa89279
      Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 b8 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f5efbc31168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f5efab9bf80 RCX: 00007f5efaa89279
      RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000005
      RBP: 00007f5efaae32e9 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 00007f5efb0cfb1f R14: 00007f5efbc31300 R15: 0000000000022000
      </TASK>
      
      Allocated by task 21027:
      kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
      kasan_set_track mm/kasan/common.c:45 [inline]
      set_alloc_info mm/kasan/common.c:437 [inline]
      ____kasan_kmalloc mm/kasan/common.c:516 [inline]
      ____kasan_kmalloc mm/kasan/common.c:475 [inline]
      __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:525
      kmalloc_node include/linux/slab.h:623 [inline]
      kzalloc_node include/linux/slab.h:744 [inline]
      qdisc_alloc+0xb0/0xc50 net/sched/sch_generic.c:938
      qdisc_create_dflt+0x71/0x4a0 net/sched/sch_generic.c:997
      attach_one_default_qdisc net/sched/sch_generic.c:1152 [inline]
      netdev_for_each_tx_queue include/linux/netdevice.h:2437 [inline]
      attach_default_qdiscs net/sched/sch_generic.c:1170 [inline]
      dev_activate+0x760/0xcd0 net/sched/sch_generic.c:1229
      __dev_open+0x393/0x4d0 net/core/dev.c:1441
      __dev_change_flags+0x583/0x750 net/core/dev.c:8556
      rtnl_configure_link+0xee/0x240 net/core/rtnetlink.c:3189
      rtnl_newlink_create net/core/rtnetlink.c:3371 [inline]
      __rtnl_newlink+0x10b8/0x17e0 net/core/rtnetlink.c:3580
      rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3593
      rtnetlink_rcv_msg+0x43a/0xca0 net/core/rtnetlink.c:6090
      netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
      netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
      netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
      netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
      sock_sendmsg_nosec net/socket.c:714 [inline]
      sock_sendmsg+0xcf/0x120 net/socket.c:734
      ____sys_sendmsg+0x6eb/0x810 net/socket.c:2482
      ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
      __sys_sendmsg+0xf3/0x1c0 net/socket.c:2565
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 21020:
      kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
      kasan_set_track+0x21/0x30 mm/kasan/common.c:45
      kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
      ____kasan_slab_free mm/kasan/common.c:367 [inline]
      ____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:329
      kasan_slab_free include/linux/kasan.h:200 [inline]
      slab_free_hook mm/slub.c:1754 [inline]
      slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1780
      slab_free mm/slub.c:3534 [inline]
      kfree+0xe2/0x580 mm/slub.c:4562
      rcu_do_batch kernel/rcu/tree.c:2245 [inline]
      rcu_core+0x7b5/0x1890 kernel/rcu/tree.c:2505
      __do_softirq+0x1d3/0x9c6 kernel/softirq.c:571
      
      Last potentially related work creation:
      kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
      __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
      call_rcu+0x99/0x790 kernel/rcu/tree.c:2793
      qdisc_put+0xcd/0xe0 net/sched/sch_generic.c:1083
      notify_and_destroy net/sched/sch_api.c:1012 [inline]
      qdisc_graft+0xeb1/0x1270 net/sched/sch_api.c:1084
      tc_modify_qdisc+0xbb7/0x1a00 net/sched/sch_api.c:1671
      rtnetlink_rcv_msg+0x43a/0xca0 net/core/rtnetlink.c:6090
      netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
      netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
      netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
      netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
      sock_sendmsg_nosec net/socket.c:714 [inline]
      sock_sendmsg+0xcf/0x120 net/socket.c:734
      ____sys_sendmsg+0x6eb/0x810 net/socket.c:2482
      ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
      __sys_sendmsg+0xf3/0x1c0 net/socket.c:2565
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Second to last potentially related work creation:
      kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
      __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
      kvfree_call_rcu+0x74/0x940 kernel/rcu/tree.c:3322
      neigh_destroy+0x431/0x630 net/core/neighbour.c:912
      neigh_release include/net/neighbour.h:454 [inline]
      neigh_cleanup_and_release+0x1f8/0x330 net/core/neighbour.c:103
      neigh_del net/core/neighbour.c:225 [inline]
      neigh_remove_one+0x37d/0x460 net/core/neighbour.c:246
      neigh_forced_gc net/core/neighbour.c:276 [inline]
      neigh_alloc net/core/neighbour.c:447 [inline]
      ___neigh_create+0x18b5/0x29a0 net/core/neighbour.c:642
      ip6_finish_output2+0xfb8/0x1520 net/ipv6/ip6_output.c:125
      __ip6_finish_output net/ipv6/ip6_output.c:195 [inline]
      ip6_finish_output+0x690/0x1160 net/ipv6/ip6_output.c:206
      NF_HOOK_COND include/linux/netfilter.h:296 [inline]
      ip6_output+0x1ed/0x540 net/ipv6/ip6_output.c:227
      dst_output include/net/dst.h:451 [inline]
      NF_HOOK include/linux/netfilter.h:307 [inline]
      NF_HOOK include/linux/netfilter.h:301 [inline]
      mld_sendpack+0xa09/0xe70 net/ipv6/mcast.c:1820
      mld_send_cr net/ipv6/mcast.c:2121 [inline]
      mld_ifc_work+0x71c/0xdc0 net/ipv6/mcast.c:2653
      process_one_work+0x991/0x1610 kernel/workqueue.c:2289
      worker_thread+0x665/0x1080 kernel/workqueue.c:2436
      kthread+0x2e4/0x3a0 kernel/kthread.c:376
      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
      
      The buggy address belongs to the object at ffff88802065e000
      which belongs to the cache kmalloc-1k of size 1024
      The buggy address is located 56 bytes inside of
      1024-byte region [ffff88802065e000, ffff88802065e400)
      
      The buggy address belongs to the physical page:
      page:ffffea0000819600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x20658
      head:ffffea0000819600 order:3 compound_mapcount:0 compound_pincount:0
      flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
      raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888011841dc0
      raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3523, tgid 3523 (sshd), ts 41495190986, free_ts 41417713212
      prep_new_page mm/page_alloc.c:2532 [inline]
      get_page_from_freelist+0x109b/0x2ce0 mm/page_alloc.c:4283
      __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5515
      alloc_pages+0x1a6/0x270 mm/mempolicy.c:2270
      alloc_slab_page mm/slub.c:1824 [inline]
      allocate_slab+0x27e/0x3d0 mm/slub.c:1969
      new_slab mm/slub.c:2029 [inline]
      ___slab_alloc+0x7f1/0xe10 mm/slub.c:3031
      __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118
      slab_alloc_node mm/slub.c:3209 [inline]
      __kmalloc_node_track_caller+0x2f2/0x380 mm/slub.c:4955
      kmalloc_reserve net/core/skbuff.c:358 [inline]
      __alloc_skb+0xd9/0x2f0 net/core/skbuff.c:430
      alloc_skb_fclone include/linux/skbuff.h:1307 [inline]
      tcp_stream_alloc_skb+0x38/0x580 net/ipv4/tcp.c:861
      tcp_sendmsg_locked+0xc36/0x2f80 net/ipv4/tcp.c:1325
      tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1483
      inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819
      sock_sendmsg_nosec net/socket.c:714 [inline]
      sock_sendmsg+0xcf/0x120 net/socket.c:734
      sock_write_iter+0x291/0x3d0 net/socket.c:1108
      call_write_iter include/linux/fs.h:2187 [inline]
      new_sync_write fs/read_write.c:491 [inline]
      vfs_write+0x9e9/0xdd0 fs/read_write.c:578
      ksys_write+0x1e8/0x250 fs/read_write.c:631
      page last free stack trace:
      reset_page_owner include/linux/page_owner.h:24 [inline]
      free_pages_prepare mm/page_alloc.c:1449 [inline]
      free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1499
      free_unref_page_prepare mm/page_alloc.c:3380 [inline]
      free_unref_page+0x19/0x4d0 mm/page_alloc.c:3476
      __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2548
      qlink_free mm/kasan/quarantine.c:168 [inline]
      qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
      kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
      __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:447
      kasan_slab_alloc include/linux/kasan.h:224 [inline]
      slab_post_alloc_hook mm/slab.h:727 [inline]
      slab_alloc_node mm/slub.c:3243 [inline]
      slab_alloc mm/slub.c:3251 [inline]
      __kmem_cache_alloc_lru mm/slub.c:3258 [inline]
      kmem_cache_alloc+0x267/0x3b0 mm/slub.c:3268
      kmem_cache_zalloc include/linux/slab.h:723 [inline]
      alloc_buffer_head+0x20/0x140 fs/buffer.c:2974
      alloc_page_buffers+0x280/0x790 fs/buffer.c:829
      create_empty_buffers+0x2c/0xee0 fs/buffer.c:1558
      ext4_block_write_begin+0x1004/0x1530 fs/ext4/inode.c:1074
      ext4_da_write_begin+0x422/0xae0 fs/ext4/inode.c:2996
      generic_perform_write+0x246/0x560 mm/filemap.c:3738
      ext4_buffered_write_iter+0x15b/0x460 fs/ext4/file.c:270
      ext4_file_write_iter+0x44a/0x1660 fs/ext4/file.c:679
      call_write_iter include/linux/fs.h:2187 [inline]
      new_sync_write fs/read_write.c:491 [inline]
      vfs_write+0x9e9/0xdd0 fs/read_write.c:578
      
      Fixes: af356afa
      
       ("net_sched: reintroduce dev->qdisc for use by sch_api")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Diagnosed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20221018203258.2793282-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarZubin Mithra <zsm@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f5c0e0a
    • Eric Dumazet's avatar
      net_sched: add __rcu annotation to netdev->qdisc · 22d95b54
      Eric Dumazet authored
      commit 5891cd5e upstream.
      
      syzbot found a data-race [1] which lead me to add __rcu
      annotations to netdev->qdisc, and proper accessors
      to get LOCKDEP support.
      
      [1]
      BUG: KCSAN: data-race in dev_activate / qdisc_lookup_rcu
      
      write to 0xffff888168ad6410 of 8 bytes by task 13559 on cpu 1:
       attach_default_qdiscs net/sched/sch_generic.c:1167 [inline]
       dev_activate+0x2ed/0x8f0 net/sched/sch_generic.c:1221
       __dev_open+0x2e9/0x3a0 net/core/dev.c:1416
       __dev_change_flags+0x167/0x3f0 net/core/dev.c:8139
       rtnl_configure_link+0xc2/0x150 net/core/rtnetlink.c:3150
       __rtnl_newlink net/core/rtnetlink.c:3489 [inline]
       rtnl_newlink+0xf4d/0x13e0 net/core/rtnetlink.c:3529
       rtnetlink_rcv_msg+0x745/0x7e0 net/core/rtnetlink.c:5594
       netlink_rcv_skb+0x14e/0x250 net/netlink/af_netlink.c:2494
       rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:5612
       netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
       netlink_unicast+0x602/0x6d0 net/netlink/af_netlink.c:1343
       netlink_sendmsg+0x728/0x850 net/netlink/af_netlink.c:1919
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg net/socket.c:725 [inline]
       ____sys_sendmsg+0x39a/0x510 net/socket.c:2413
       ___sys_sendmsg net/socket.c:2467 [inline]
       __sys_sendmsg+0x195/0x230 net/socket.c:2496
       __do_sys_sendmsg net/socket.c:2505 [inline]
       __se_sys_sendmsg net/socket.c:2503 [inline]
       __x64_sys_sendmsg+0x42/0x50 net/socket.c:2503
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff888168ad6410 of 8 bytes by task 13560 on cpu 0:
       qdisc_lookup_rcu+0x30/0x2e0 net/sched/sch_api.c:323
       __tcf_qdisc_find+0x74/0x3a0 net/sched/cls_api.c:1050
       tc_del_tfilter+0x1c7/0x1350 net/sched/cls_api.c:2211
       rtnetlink_rcv_msg+0x5ba/0x7e0 net/core/rtnetlink.c:5585
       netlink_rcv_skb+0x14e/0x250 net/netlink/af_netlink.c:2494
       rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:5612
       netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
       netlink_unicast+0x602/0x6d0 net/netlink/af_netlink.c:1343
       netlink_sendmsg+0x728/0x850 net/netlink/af_netlink.c:1919
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg net/socket.c:725 [inline]
       ____sys_sendmsg+0x39a/0x510 net/socket.c:2413
       ___sys_sendmsg net/socket.c:2467 [inline]
       __sys_sendmsg+0x195/0x230 net/socket.c:2496
       __do_sys_sendmsg net/socket.c:2505 [inline]
       __se_sys_sendmsg net/socket.c:2503 [inline]
       __x64_sys_sendmsg+0x42/0x50 net/socket.c:2503
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0xffffffff85dee080 -> 0xffff88815d96ec00
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 13560 Comm: syz-executor.2 Not tainted 5.17.0-rc3-syzkaller-00116-gf1baf68e1383-dirty #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 470502de
      
       ("net: sched: unlock rules update API")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Vlad Buslov <vladbu@mellanox.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarZubin Mithra <zsm@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22d95b54
    • Ye Bin's avatar
      ext4: fix kernel BUG in 'ext4_write_inline_data_end()' · 14b6ad56
      Ye Bin authored
      commit 5c099c4f upstream.
      
      Syzbot report follow issue:
      ------------[ cut here ]------------
      kernel BUG at fs/ext4/inline.c:227!
      invalid opcode: 0000 [#1] PREEMPT SMP KASAN
      CPU: 1 PID: 3629 Comm: syz-executor212 Not tainted 6.1.0-rc5-syzkaller-00018-g59d0d52c30d4 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
      RIP: 0010:ext4_write_inline_data+0x344/0x3e0 fs/ext4/inline.c:227
      RSP: 0018:ffffc90003b3f368 EFLAGS: 00010293
      RAX: 0000000000000000 RBX: ffff8880704e16c0 RCX: 0000000000000000
      RDX: ffff888021763a80 RSI: ffffffff821e31a4 RDI: 0000000000000006
      RBP: 000000000006818e R08: 0000000000000006 R09: 0000000000068199
      R10: 0000000000000079 R11: 0000000000000000 R12: 000000000000000b
      R13: 0000000000068199 R14: ffffc90003b3f408 R15: ffff8880704e1c82
      FS:  000055555723e3c0(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fffe8ac9080 CR3: 0000000079f81000 CR4: 0000000000350ee0
      Call Trace:
       <TASK>
       ext4_write_inline_data_end+0x2a3/0x12f0 fs/ext4/inline.c:768
       ext4_write_end+0x242/0xdd0 fs/ext4/inode.c:1313
       ext4_da_write_end+0x3ed/0xa30 fs/ext4/inode.c:3063
       generic_perform_write+0x316/0x570 mm/filemap.c:3764
       ext4_buffered_write_iter+0x15b/0x460 fs/ext4/file.c:285
       ext4_file_write_iter+0x8bc/0x16e0 fs/ext4/file.c:700
       call_write_iter include/linux/fs.h:2191 [inline]
       do_iter_readv_writev+0x20b/0x3b0 fs/read_write.c:735
       do_iter_write+0x182/0x700 fs/read_write.c:861
       vfs_iter_write+0x74/0xa0 fs/read_write.c:902
       iter_file_splice_write+0x745/0xc90 fs/splice.c:686
       do_splice_from fs/splice.c:764 [inline]
       direct_splice_actor+0x114/0x180 fs/splice.c:931
       splice_direct_to_actor+0x335/0x8a0 fs/splice.c:886
       do_splice_direct+0x1ab/0x280 fs/splice.c:974
       do_sendfile+0xb19/0x1270 fs/read_write.c:1255
       __do_sys_sendfile64 fs/read_write.c:1323 [inline]
       __se_sys_sendfile64 fs/read_write.c:1309 [inline]
       __x64_sys_sendfile64+0x1d0/0x210 fs/read_write.c:1309
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      ---[ end trace 0000000000000000 ]---
      
      Above issue may happens as follows:
      ext4_da_write_begin
        ext4_da_write_inline_data_begin
          ext4_da_convert_inline_data_to_extent
            ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
      ext4_da_write_end
      
      ext4_run_li_request
        ext4_mb_prefetch
          ext4_read_block_bitmap_nowait
            ext4_validate_block_bitmap
              ext4_mark_group_bitmap_corrupted(sb, block_group, EXT4_GROUP_INFO_BBITMAP_CORRUPT)
      	 percpu_counter_sub(&sbi->s_freeclusters_counter,grp->bb_free);
      	  -> sbi->s_freeclusters_counter become zero
      ext4_da_write_begin
        if (ext4_nonda_switch(inode->i_sb)) -> As freeclusters_counter is zero will return true
          *fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
          ext4_write_begin
      ext4_da_write_end
        if (write_mode == FALL_BACK_TO_NONDELALLOC)
          ext4_write_end
            if (inline_data)
              ext4_write_inline_data_end
      	  ext4_write_inline_data
      	    BUG_ON(pos + len > EXT4_I(inode)->i_inline_size);
                 -> As inode is already convert to extent, so 'pos + len' > inline_size
      	   -> then trigger BUG.
      
      To solve this issue, instead of checking ext4_has_inline_data() which
      is only cleared after data has been written back, check the
      EXT4_STATE_MAY_INLINE_DATA flag in ext4_write_end().
      
      Fixes: f19d5870
      
       ("ext4: add normal write support for inline data")
      Reported-by: default avatar <syzbot+4faa160fa96bfba639f8@syzkaller.appspotmail.com>
      Reported-by: default avatarJun Nie <jun.nie@linaro.org>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Link: https://lore.kernel.org/r/20221206144134.1919987-1-yebin@huaweicloud.com
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      [ta: Fix conflict in if expression and use the local variable inline_data
      as it is initialized with ext4_has_inline_data(inode) anyway.]
      Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14b6ad56
    • Anand Jain's avatar
      btrfs: scan device in non-exclusive mode · 9b189af3
      Anand Jain authored
      commit 50d281fc
      
       upstream.
      
      This fixes mkfs/mount/check failures due to race with systemd-udevd
      scan.
      
      During the device scan initiated by systemd-udevd, other user space
      EXCL operations such as mkfs, mount, or check may get blocked and result
      in a "Device or resource busy" error. This is because the device
      scan process opens the device with the EXCL flag in the kernel.
      
      Two reports were received:
      
       - btrfs/179 test case, where the fsck command failed with the -EBUSY
         error
      
       - LTP pwritev03 test case, where mkfs.vfs failed with
         the -EBUSY error, when mkfs.vfs tried to overwrite old btrfs filesystem
         on the device.
      
      In both cases, fsck and mkfs (respectively) were racing with a
      systemd-udevd device scan, and systemd-udevd won, resulting in the
      -EBUSY error for fsck and mkfs.
      
      Reproducing the problem has been difficult because there is a very
      small window during which these userspace threads can race to
      acquire the exclusive device open. Even on the system where the problem
      was observed, the problem occurrences were anywhere between 10 to 400
      iterations and chances of reproducing decreases with debug printk()s.
      
      However, an exclusive device open is unnecessary for the scan process,
      as there are no write operations on the device during scan. Furthermore,
      during the mount process, the superblock is re-read in the below
      function call chain:
      
        btrfs_mount_root
         btrfs_open_devices
          open_fs_devices
           btrfs_open_one_device
             btrfs_get_bdev_and_sb
      
      So, to fix this issue, removes the FMODE_EXCL flag from the scan
      operation, and add a comment.
      
      The case where mkfs may still write to the device and a scan is running,
      the btrfs signature is not written at that time so scan will not
      recognize such device.
      
      Reported-by: default avatarSherry Yang <sherry.yang@oracle.com>
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Link: https://lore.kernel.org/oe-lkp/202303170839.fdf23068-oliver.sang@intel.com
      
      
      CC: stable@vger.kernel.org # 5.4+
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b189af3
    • Heiko Carstens's avatar
      s390/uaccess: add missing earlyclobber annotations to __clear_user() · 45a9877d
      Heiko Carstens authored
      commit 89aba4c2 upstream.
      
      Add missing earlyclobber annotation to size, to, and tmp2 operands of the
      __clear_user() inline assembly since they are modified or written to before
      the last usage of all input operands. This can lead to incorrect register
      allocation for the inline assembly.
      
      Fixes: 6c2a9e6d
      
       ("[S390] Use alternative user-copy operations for new hardware.")
      Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
      Link: https://lore.kernel.org/all/20230321122514.1743889-3-mark.rutland@arm.com/
      
      
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45a9877d
    • Lucas Stach's avatar
      drm/etnaviv: fix reference leak when mmaping imported buffer · 0c6df536
      Lucas Stach authored
      commit 963b2e8c
      
       upstream.
      
      drm_gem_prime_mmap() takes a reference on the GEM object, but before that
      drm_gem_mmap_obj() already takes a reference, which will be leaked as only
      one reference is dropped when the mapping is closed. Drop the extra
      reference when dma_buf_mmap() succeeds.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Reviewed-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c6df536
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix regression on detection of Roland VS-100 · 37958ac3
      Takashi Iwai authored
      commit fa4e7a6f upstream.
      
      It's been reported that the recent kernel can't probe the PCM devices
      on Roland VS-100 properly, and it turned out to be a regression by the
      recent addition of the bit shift range check for the format bits.
      In the old code, we just did bit-shift and it resulted in zero, which
      is then corrected to the standard PCM format, while the new code
      explicitly returns an error in such a case.
      
      For addressing the regression, relax the check and fallback to the
      standard PCM type (with the info output).
      
      Fixes: 43d5ca88 ("ALSA: usb-audio: Fix potential out-of-bounds shift")
      Cc: <stable@vger.kernel.org>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=217084
      Link: https://lore.kernel.org/r/20230324075005.19403-1-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37958ac3
    • Takashi Iwai's avatar
      ALSA: hda/conexant: Partial revert of a quirk for Lenovo · 6dabafd8
      Takashi Iwai authored
      commit b871cb97 upstream.
      
      The recent commit f83bb259 ("ALSA: hda/conexant: Add quirk for
      LENOVO 20149 Notebook model") introduced a quirk for the device with
      17aa:3977, but this caused a regression on another model (Lenovo
      Ideadpad U31) with the very same PCI SSID.  And, through skimming over
      the net, it seems that this PCI SSID is used for multiple different
      models, so it's no good idea to apply the quirk with the SSID.
      
      Although we may take a different ID check (e.g. the codec SSID instead
      of the PCI SSID), unfortunately, the original patch author couldn't
      identify the hardware details any longer as the machine was returned,
      and we can't develop the further proper fix.
      
      In this patch, instead, we partially revert the change so that the
      quirk won't be applied as default for addressing the regression.
      Meanwhile, the quirk function itself is kept, and it's now made to be
      applicable via the explicit model=lenovo-20149 option.
      
      Fixes: f83bb259
      
       ("ALSA: hda/conexant: Add quirk for LENOVO 20149 Notebook model")
      Reported-by: default avatarJetro Jormalainen <jje-lxkl@jetro.fi>
      Link: https://lore.kernel.org/r/20230308215009.4d3e58a6@mopti
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20230320140954.31154-1-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dabafd8
    • Trond Myklebust's avatar
      NFSv4: Fix hangs when recovering open state after a server reboot · f3a67268
      Trond Myklebust authored
      commit 6165a16a upstream.
      
      When we're using a cached open stateid or a delegation in order to avoid
      sending a CLAIM_PREVIOUS open RPC call to the server, we don't have a
      new open stateid to present to update_open_stateid().
      Instead rely on nfs4_try_open_cached(), just as if we were doing a
      normal open.
      
      Fixes: d2bfda2e
      
       ("NFSv4: don't reprocess cached open CLAIM_PREVIOUS")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3a67268
    • Johan Hovold's avatar
      pinctrl: at91-pio4: fix domain name assignment · c81e2965
      Johan Hovold authored
      commit 7bb97e36 upstream.
      
      Since commit d59f6617 ("genirq: Allow fwnode to carry name
      information only") an IRQ domain is always given a name during
      allocation (e.g. used for the debugfs entry).
      
      Drop the no longer valid name assignment, which would lead to an attempt
      to free a string constant when removing the domain on late probe
      failures (e.g. probe deferral).
      
      Fixes: d59f6617
      
       ("genirq: Allow fwnode to carry name information only")
      Cc: stable@vger.kernel.org	# 4.13
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
      Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com> # on SAMA7G5
      Link: https://lore.kernel.org/r/20230224130828.27985-1-johan+linaro@kernel.org
      
      
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c81e2965
    • Juergen Gross's avatar
      xen/netback: don't do grant copy across page boundary · 82c25ac3
      Juergen Gross authored
      commit 05310f31 upstream.
      
      Fix xenvif_get_requests() not to do grant copy operations across local
      page boundaries. This requires to double the maximum number of copy
      operations per queue, as each copy could now be split into 2.
      
      Make sure that struct xenvif_tx_cb doesn't grow too large.
      
      Cc: stable@vger.kernel.org
      Fixes: ad7f402a
      
       ("xen/netback: Ensure protocol headers don't fall in the non-linear area")
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82c25ac3
    • Hans de Goede's avatar
      Input: goodix - add Lenovo Yoga Book X90F to nine_bytes_report DMI table · 99c8ba92
      Hans de Goede authored
      commit 8a0432ba
      
       upstream.
      
      The Android Lenovo Yoga Book X90F / X90L uses the same goodix touchscreen
      with 9 bytes touch reports for its touch keyboard as the already supported
      Windows Lenovo Yoga Book X91F/L, add a DMI match for this to
      the nine_bytes_report DMI table.
      
      When the quirk for the X91F/L was initially added it was written to
      also apply to the X90F/L but this does not work because the Android
      version of the Yoga Book uses completely different DMI strings.
      Also adjust the X91F/L quirk to reflect that it only applies to
      the X91F/L models.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarBastien Nocera <hadess@hadess.net>
      Link: https://lore.kernel.org/r/20230315134442.71787-1-hdegoede@redhat.com
      
      
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      99c8ba92
    • David Disseldorp's avatar
      cifs: fix DFS traversal oops without CONFIG_CIFS_DFS_UPCALL · 657d7c21
      David Disseldorp authored
      commit 179a88a8
      
       upstream.
      
      When compiled with CONFIG_CIFS_DFS_UPCALL disabled, cifs_dfs_d_automount
      is NULL. cifs.ko logic for mapping CIFS_FATTR_DFS_REFERRAL attributes to
      S_AUTOMOUNT and corresponding dentry flags is retained regardless of
      CONFIG_CIFS_DFS_UPCALL, leading to a NULL pointer dereference in
      VFS follow_automount() when traversing a DFS referral link:
        BUG: kernel NULL pointer dereference, address: 0000000000000000
        ...
        Call Trace:
         <TASK>
         __traverse_mounts+0xb5/0x220
         ? cifs_revalidate_mapping+0x65/0xc0 [cifs]
         step_into+0x195/0x610
         ? lookup_fast+0xe2/0xf0
         path_lookupat+0x64/0x140
         filename_lookup+0xc2/0x140
         ? __create_object+0x299/0x380
         ? kmem_cache_alloc+0x119/0x220
         ? user_path_at_empty+0x31/0x50
         user_path_at_empty+0x31/0x50
         __x64_sys_chdir+0x2a/0xd0
         ? exit_to_user_mode_prepare+0xca/0x100
         do_syscall_64+0x42/0x90
         entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      This fix adds an inline cifs_dfs_d_automount() {return -EREMOTE} handler
      when CONFIG_CIFS_DFS_UPCALL is disabled. An alternative would be to
      avoid flagging S_AUTOMOUNT, etc. without CONFIG_CIFS_DFS_UPCALL. This
      approach was chosen as it provides more control over the error path.
      
      Signed-off-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      657d7c21
    • Paulo Alcantara's avatar
      cifs: prevent infinite recursion in CIFSGetDFSRefer() · 03af69bd
      Paulo Alcantara authored
      commit 09ba47b4
      
       upstream.
      
      We can't call smb_init() in CIFSGetDFSRefer() as cifs_reconnect_tcon()
      may end up calling CIFSGetDFSRefer() again to get new DFS referrals
      and thus causing an infinite recursion.
      
      Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Cc: stable@vger.kernel.org # 6.2
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03af69bd
    • Jason A. Donenfeld's avatar
      Input: focaltech - use explicitly signed char type · 51d65737
      Jason A. Donenfeld authored
      commit 8980f190 upstream.
      
      The recent change of -funsigned-char causes additions of negative
      numbers to become additions of large positive numbers, leading to wrong
      calculations of mouse movement. Change these casts to be explicitly
      signed, to take into account negative offsets.
      
      Fixes: 3bc753c0
      
       ("kbuild: treat char as always unsigned")
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Cc: stable@vger.kernel.org
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=217211
      Link: https://lore.kernel.org/r/20230318133010.1285202-1-Jason@zx2c4.com
      
      
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51d65737
    • msizanoen's avatar
      Input: alps - fix compatibility with -funsigned-char · f0f85f5e
      msizanoen authored
      commit 754ff506 upstream.
      
      The AlpsPS/2 code previously relied on the assumption that `char` is a
      signed type, which was true on x86 platforms (the only place where this
      driver is used) before kernel 6.2. However, on 6.2 and later, this
      assumption is broken due to the introduction of -funsigned-char as a new
      global compiler flag.
      
      Fix this by explicitly specifying the signedness of `char` when sign
      extending the values received from the device.
      
      Fixes: f3f33c67
      
       ("Input: alps - Rushmore and v7 resolution support")
      Signed-off-by: default avatarmsizanoen <msizanoen@qtmlabs.xyz>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230320045228.182259-1-msizanoen@qtmlabs.xyz
      
      
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0f85f5e
    • Horatiu Vultur's avatar
      pinctrl: ocelot: Fix alt mode for ocelot · 7e71d4d1
      Horatiu Vultur authored
      [ Upstream commit 657fd9da ]
      
      In case the driver was trying to set an alternate mode for gpio
      0 or 32 then the mode was not set correctly. The reason is that
      there is computation error inside the function ocelot_pinmux_set_mux
      because in this case it was trying to shift to left by -1.
      Fix this by actually shifting the function bits and not the position.
      
      Fixes: 4b36082e
      
       ("pinctrl: ocelot: fix pinmuxing for pins after 31")
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Link: https://lore.kernel.org/r/20230206203720.1177718-1-horatiu.vultur@microchip.com
      
      
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7e71d4d1
    • Lorenzo Bianconi's avatar
      net: mvneta: make tx buffer array agnostic · 70728d63
      Lorenzo Bianconi authored
      [ Upstream commit 9e58c8b4
      
       ]
      
      Allow tx buffer array to contain both skb and xdp buffers in order to
      enable xdp frame recycling adding XDP_TX verdict support
      
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 2960a2d3
      
       ("net: mvneta: fix potential double-frees in mvneta_txq_sw_deinit()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      70728d63
    • Steffen Bätz's avatar
      net: dsa: mv88e6xxx: Enable IGMP snooping on user ports only · 704e06b9
      Steffen Bätz authored
      [ Upstream commit 7bcad0f0 ]
      
      Do not set the MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP bit on CPU or DSA ports.
      
      This allows the host CPU port to be a regular IGMP listener by sending out
      IGMP Membership Reports, which would otherwise not be forwarded by the
      mv88exxx chip, but directly looped back to the CPU port itself.
      
      Fixes: 54d792f2
      
       ("net: dsa: Centralise global and port setup code into mv88e6xxx.")
      Signed-off-by: default avatarSteffen Bätz <steffen@innosonix.de>
      Signed-off-by: default avatarFabio Estevam <festevam@denx.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20230329150140.701559-1-festevam@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      704e06b9
    • Kalesh AP's avatar
      bnxt_en: Fix typo in PCI id to device description string mapping · fd7cff50
      Kalesh AP authored
      [ Upstream commit 62aad36e ]
      
      Fix 57502 and 57508 NPAR description string entries.  The typos
      caused these devices to not match up with lspci output.
      
      Fixes: 49c98421
      
       ("bnxt_en: Add PCI IDs for 57500 series NPAR devices.")
      Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
      Signed-off-by: default avatarKalesh AP <kalesh-anakkur.purayil@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fd7cff50
    • Radoslaw Tyl's avatar
      i40e: fix registers dump after run ethtool adapter self test · 58279cea
      Radoslaw Tyl authored
      [ Upstream commit c5cff16f ]
      
      Fix invalid registers dump from ethtool -d ethX after adapter self test
      by ethtool -t ethY. It causes invalid data display.
      
      The problem was caused by overwriting i40e_reg_list[].elements
      which is common for ethtool self test and dump.
      
      Fixes: 22dd9ae8
      
       ("i40e: Rework register diagnostic")
      Signed-off-by: default avatarRadoslaw Tyl <radoslawx.tyl@intel.com>
      Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
      Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Link: https://lore.kernel.org/r/20230328172659.3906413-1-anthony.l.nguyen@intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      58279cea
    • Tony Krowiak's avatar
      s390/vfio-ap: fix memory leak in vfio_ap device driver · 5195de1d
      Tony Krowiak authored
      [ Upstream commit 8f8cf767 ]
      
      The device release callback function invoked to release the matrix device
      uses the dev_get_drvdata(device *dev) function to retrieve the
      pointer to the vfio_matrix_dev object in order to free its storage. The
      problem is, this object is not stored as drvdata with the device; since the
      kfree function will accept a NULL pointer, the memory for the
      vfio_matrix_dev object is never freed.
      
      Since the device being released is contained within the vfio_matrix_dev
      object, the container_of macro will be used to retrieve its pointer.
      
      Fixes: 1fde5734
      
       ("s390: vfio-ap: base implementation of VFIO AP device driver")
      Signed-off-by: default avatarTony Krowiak <akrowiak@linux.ibm.com>
      Reviewed-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230320150447.34557-1-akrowiak@linux.ibm.com
      
      
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5195de1d
    • Ivan Orlov's avatar
      can: bcm: bcm_tx_setup(): fix KMSAN uninit-value in vfs_write · 78bc7f0a
      Ivan Orlov authored
      [ Upstream commit 2b4c99f7
      
       ]
      
      Syzkaller reported the following issue:
      
      =====================================================
      BUG: KMSAN: uninit-value in aio_rw_done fs/aio.c:1520 [inline]
      BUG: KMSAN: uninit-value in aio_write+0x899/0x950 fs/aio.c:1600
       aio_rw_done fs/aio.c:1520 [inline]
       aio_write+0x899/0x950 fs/aio.c:1600
       io_submit_one+0x1d1c/0x3bf0 fs/aio.c:2019
       __do_sys_io_submit fs/aio.c:2078 [inline]
       __se_sys_io_submit+0x293/0x770 fs/aio.c:2048
       __x64_sys_io_submit+0x92/0xd0 fs/aio.c:2048
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Uninit was created at:
       slab_post_alloc_hook mm/slab.h:766 [inline]
       slab_alloc_node mm/slub.c:3452 [inline]
       __kmem_cache_alloc_node+0x71f/0xce0 mm/slub.c:3491
       __do_kmalloc_node mm/slab_common.c:967 [inline]
       __kmalloc+0x11d/0x3b0 mm/slab_common.c:981
       kmalloc_array include/linux/slab.h:636 [inline]
       bcm_tx_setup+0x80e/0x29d0 net/can/bcm.c:930
       bcm_sendmsg+0x3a2/0xce0 net/can/bcm.c:1351
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg net/socket.c:734 [inline]
       sock_write_iter+0x495/0x5e0 net/socket.c:1108
       call_write_iter include/linux/fs.h:2189 [inline]
       aio_write+0x63a/0x950 fs/aio.c:1600
       io_submit_one+0x1d1c/0x3bf0 fs/aio.c:2019
       __do_sys_io_submit fs/aio.c:2078 [inline]
       __se_sys_io_submit+0x293/0x770 fs/aio.c:2048
       __x64_sys_io_submit+0x92/0xd0 fs/aio.c:2048
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      CPU: 1 PID: 5034 Comm: syz-executor350 Not tainted 6.2.0-rc6-syzkaller-80422-geda666ff2276 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
      =====================================================
      
      We can follow the call chain and find that 'bcm_tx_setup' function
      calls 'memcpy_from_msg' to copy some content to the newly allocated
      frame of 'op->frames'. After that the 'len' field of copied structure
      being compared with some constant value (64 or 8). However, if
      'memcpy_from_msg' returns an error, we will compare some uninitialized
      memory. This triggers 'uninit-value' issue.
      
      This patch will add 'memcpy_from_msg' possible errors processing to
      avoid uninit-value issue.
      
      Tested via syzkaller
      
      Reported-by: default avatar <syzbot+c9bfd85eca611ebf5db1@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=47f897f8ad958bbde5790ebf389b5e7e0a345089
      
      
      Signed-off-by: default avatarIvan Orlov <ivan.orlov0322@gmail.com>
      Fixes: 6f3b911d
      
       ("can: bcm: add support for CAN FD frames")
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Link: https://lore.kernel.org/all/20230314120445.12407-1-ivan.orlov0322@gmail.com
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      78bc7f0a
    • Faicker Mo's avatar
      net/net_failover: fix txq exceeding warning · 105cc268
      Faicker Mo authored
      [ Upstream commit e3cbdcb0 ]
      
      The failover txq is inited as 16 queues.
      when a packet is transmitted from the failover device firstly,
      the failover device will select the queue which is returned from
      the primary device if the primary device is UP and running.
      If the primary device txq is bigger than the default 16,
      it can lead to the following warning:
      eth0 selects TX queue 18, but real number of TX queues is 16
      
      The warning backtrace is:
      [   32.146376] CPU: 18 PID: 9134 Comm: chronyd Tainted: G            E      6.2.8-1.el7.centos.x86_64 #1
      [   32.147175] Hardware name: Red Hat KVM, BIOS 1.10.2-3.el7_4.1 04/01/2014
      [   32.147730] Call Trace:
      [   32.147971]  <TASK>
      [   32.148183]  dump_stack_lvl+0x48/0x70
      [   32.148514]  dump_stack+0x10/0x20
      [   32.148820]  netdev_core_pick_tx+0xb1/0xe0
      [   32.149180]  __dev_queue_xmit+0x529/0xcf0
      [   32.149533]  ? __check_object_size.part.0+0x21c/0x2c0
      [   32.149967]  ip_finish_output2+0x278/0x560
      [   32.150327]  __ip_finish_output+0x1fe/0x2f0
      [   32.150690]  ip_finish_output+0x2a/0xd0
      [   32.151032]  ip_output+0x7a/0x110
      [   32.151337]  ? __pfx_ip_finish_output+0x10/0x10
      [   32.151733]  ip_local_out+0x5e/0x70
      [   32.152054]  ip_send_skb+0x19/0x50
      [   32.152366]  udp_send_skb.isra.0+0x163/0x3a0
      [   32.152736]  udp_sendmsg+0xba8/0xec0
      [   32.153060]  ? __folio_memcg_unlock+0x25/0x60
      [   32.153445]  ? __pfx_ip_generic_getfrag+0x10/0x10
      [   32.153854]  ? sock_has_perm+0x85/0xa0
      [   32.154190]  inet_sendmsg+0x6d/0x80
      [   32.154508]  ? inet_sendmsg+0x6d/0x80
      [   32.154838]  sock_sendmsg+0x62/0x70
      [   32.155152]  ____sys_sendmsg+0x134/0x290
      [   32.155499]  ___sys_sendmsg+0x81/0xc0
      [   32.155828]  ? _get_random_bytes.part.0+0x79/0x1a0
      [   32.156240]  ? ip4_datagram_release_cb+0x5f/0x1e0
      [   32.156649]  ? get_random_u16+0x69/0xf0
      [   32.156989]  ? __fget_light+0xcf/0x110
      [   32.157326]  __sys_sendmmsg+0xc4/0x210
      [   32.157657]  ? __sys_connect+0xb7/0xe0
      [   32.157995]  ? __audit_syscall_entry+0xce/0x140
      [   32.158388]  ? syscall_trace_enter.isra.0+0x12c/0x1a0
      [   32.158820]  __x64_sys_sendmmsg+0x24/0x30
      [   32.159171]  do_syscall_64+0x38/0x90
      [   32.159493]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Fix that by reducing txq number as the non-existent primary-dev does.
      
      Fixes: cfc80d9a
      
       ("net: Introduce net_failover driver")
      Signed-off-by: default avatarFaicker Mo <faicker.mo@ucloud.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      105cc268
    • Christophe JAILLET's avatar
      regulator: Handle deferred clk · e633fd26
      Christophe JAILLET authored
      [ Upstream commit 02bcba0b ]
      
      devm_clk_get() can return -EPROBE_DEFER. So it is better to return the
      error code from devm_clk_get(), instead of a hard coded -ENOENT.
      
      This gives more opportunities to successfully probe the driver.
      
      Fixes: 8959e532
      
       ("regulator: fixed: add possibility to enable by clock")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Link: https://lore.kernel.org/r/18459fae3d017a66313699c7c8456b28158b2dd0.1679819354.git.christophe.jaillet@wanadoo.fr
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e633fd26
    • Colin Ian King's avatar
      regulator: fix spelling mistake "Cant" -> "Can't" · be7b622c
      Colin Ian King authored
      [ Upstream commit 09dad81e
      
       ]
      
      There is a spelling mistake in a dev_err message. Fix it.
      
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Link: https://lore.kernel.org/r/20200810093931.50624-1-colin.king@canonical.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Stable-dep-of: 02bcba0b
      
       ("regulator: Handle deferred clk")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      be7b622c
    • SongJingyi's avatar
      ptp_qoriq: fix memory leak in probe() · 46c4993a
      SongJingyi authored
      [ Upstream commit f3364222 ]
      
      Smatch complains that:
      drivers/ptp/ptp_qoriq.c ptp_qoriq_probe()
      warn: 'base' from ioremap() not released.
      
      Fix this by revising the parameter from 'ptp_qoriq->base' to 'base'.
      This is only a bug if ptp_qoriq_init() returns on the
      first -ENODEV error path.
      For other error paths ptp_qoriq->base and base are the same.
      And this change makes the code more readable.
      
      Fixes: 7f4399ba
      
       ("ptp_qoriq: fix NULL access if ptp dt node missing")
      Signed-off-by: default avatarSongJingyi <u201912584@hust.edu.cn>
      Reviewed-by: default avatarDan Carpenter <error27@gmail.com>
      Reviewed-by: default avatarDongliang Mu <dzm91@hust.edu.cn>
      Link: https://lore.kernel.org/r/20230324031406.1895159-1-u201912584@hust.edu.cn
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      46c4993a
    • Tomas Henzl's avatar
      scsi: megaraid_sas: Fix crash after a double completion · c122daa0
      Tomas Henzl authored
      [ Upstream commit 2309df27 ]
      
      When a physical disk is attached directly "without JBOD MAP support" (see
      megasas_get_tm_devhandle()) then there is no real error handling in the
      driver.  Return FAILED instead of SUCCESS.
      
      Fixes: 18365b13
      
       ("megaraid_sas: Task management support")
      Signed-off-by: default avatarTomas Henzl <thenzl@redhat.com>
      Link: https://lore.kernel.org/r/20230324150134.14696-1-thenzl@redhat.com
      
      
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c122daa0
    • Arseniy Krasnov's avatar
      mtd: rawnand: meson: invalidate cache on polling ECC bit · 317c07d3
      Arseniy Krasnov authored
      [ Upstream commit e732e39e ]
      
      'info_buf' memory is cached and driver polls ECC bit in it. This bit
      is set by the NAND controller. If 'usleep_range()' returns before device
      sets this bit, 'info_buf' will be cached and driver won't see update of
      this bit and will loop forever.
      
      Fixes: 8fae856c
      
       ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")
      Signed-off-by: default avatarArseniy Krasnov <AVKrasnov@sberdevices.ru>
      Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/d4ef0bd6-816e-f6fa-9385-f05f775f0ae2@sberdevices.ru
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      317c07d3
    • Álvaro Fernández Rojas's avatar
      mips: bmips: BCM6358: disable RAC flush for TP1 · d65de5ee
      Álvaro Fernández Rojas authored
      [ Upstream commit ab327f8a ]
      
      RAC flush causes kernel panics on BCM6358 with EHCI/OHCI when booting from TP1:
      [    3.881739] usb 1-1: new high-speed USB device number 2 using ehci-platform
      [    3.895011] Reserved instruction in kernel code[#1]:
      [    3.900113] CPU: 0 PID: 1 Comm: init Not tainted 5.10.16 #0
      [    3.905829] $ 0   : 00000000 10008700 00000000 77d94060
      [    3.911238] $ 4   : 7fd1f088 00000000 81431cac 81431ca0
      [    3.916641] $ 8   : 00000000 ffffefff 8075cd34 00000000
      [    3.922043] $12   : 806f8d40 f3e812b7 00000000 000d9aaa
      [    3.927446] $16   : 7fd1f068 7fd1f080 7ff559b8 81428470
      [    3.932848] $20   : 00000000 00000000 55590000 77d70000
      [    3.938251] $24   : 00000018 00000010
      [    3.943655] $28   : 81430000 81431e60 81431f28 800157fc
      [    3.949058] Hi    : 00000000
      [    3.952013] Lo    : 00000000
      [    3.955019] epc   : 80015808 setup_sigcontext+0x54/0x24c
      [    3.960464] ra    : 800157fc setup_sigcontext+0x48/0x24c
      [    3.965913] Status: 10008703	KERNEL EXL IE
      [    3.970216] Cause : 00800028 (ExcCode 0a)
      [    3.974340] PrId  : 0002a010 (Broadcom BMIPS4350)
      [    3.979170] Modules linked in: ohci_platform ohci_hcd fsl_mph_dr_of ehci_platform ehci_fsl ehci_hcd gpio_button_hotplug usbcore nls_base usb_common
      [    3.992907] Process init (pid: 1, threadinfo=(ptrval), task=(ptrval), tls=77e22ec8)
      [    4.000776] Stack : 81431ef4 7fd1f080 81431f28 81428470 7fd1f068 81431edc 7ff559b8 81428470
      [    4.009467]         81431f28 7fd1f080 55590000 77d70000 77d5498c 80015c70 806f0000 8063ae74
      [    4.018149]         08100002 81431f28 0000000a 08100002 81431f28 0000000a 77d6b418 00000003
      [    4.026831]         ffffffff 80016414 80080734 81431ecc 81431ecc 00000001 00000000 04000000
      [    4.035512]         77d54874 00000000 00000000 00000000 00000000 00000012 00000002 00000000
      [    4.044196]         ...
      [    4.046706] Call Trace:
      [    4.049238] [<80015808>] setup_sigcontext+0x54/0x24c
      [    4.054356] [<80015c70>] setup_frame+0xdc/0x124
      [    4.059015] [<80016414>] do_notify_resume+0x1dc/0x288
      [    4.064207] [<80011b50>] work_notifysig+0x10/0x18
      [    4.069036]
      [    4.070538] Code: 8fc300b4  00001025  26240008 <ac820000> ac830004  3c048063  0c0228aa  24846a00  26240010
      [    4.080686]
      [    4.082517] ---[ end trace 22a8edb41f5f983b ]---
      [    4.087374] Kernel panic - not syncing: Fatal exception
      [    4.092753] Rebooting in 1 seconds..
      
      Because the bootloader (CFE) is not initializing the Read-ahead cache properly
      on the second thread (TP1). Since the RAC was not initialized properly, we
      should avoid flushing it at the risk of corrupting the instruction stream as
      seen in the trace above.
      
      Fixes: d59098a0
      
       ("MIPS: bmips: use generic dma noncoherent ops")
      Signed-off-by: default avatarÁlvaro Fernández Rojas <noltari@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d65de5ee
    • Christoph Hellwig's avatar
      dma-mapping: drop the dev argument to arch_sync_dma_for_* · 9690e34f
      Christoph Hellwig authored
      [ Upstream commit 56e35f9c
      
       ]
      
      These are pure cache maintainance routines, so drop the unused
      struct device argument.
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Suggested-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Stable-dep-of: ab327f8a
      
       ("mips: bmips: BCM6358: disable RAC flush for TP1")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9690e34f
    • Harshit Mogalapalli's avatar
      ca8210: Fix unsigned mac_len comparison with zero in ca8210_skb_tx() · f6e2d76a
      Harshit Mogalapalli authored
      [ Upstream commit 748b2f5e ]
      
      mac_len is of type unsigned, which can never be less than zero.
      
      	mac_len = ieee802154_hdr_peek_addrs(skb, &header);
      	if (mac_len < 0)
      		return mac_len;
      
      Change this to type int as ieee802154_hdr_peek_addrs() can return negative
      integers, this is found by static analysis with smatch.
      
      Fixes: 6c993779
      
       ("ca8210: fix mac_len negative array access")
      Signed-off-by: default avatarHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230306191824.4115839-1-harshit.m.mogalapalli@oracle.com
      
      
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f6e2d76a
    • Wei Chen's avatar
      fbdev: au1200fb: Fix potential divide by zero · 856fb74f
      Wei Chen authored
      [ Upstream commit 44a3b36b
      
       ]
      
      var->pixclock can be assigned to zero by user. Without
      proper check, divide by zero would occur when invoking
      macro PICOS2KHZ in au1200fb_fb_check_var.
      
      Error out if var->pixclock is zero.
      
      Signed-off-by: default avatarWei Chen <harperchen1110@gmail.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      856fb74f
    • Wei Chen's avatar
      fbdev: lxfb: Fix potential divide by zero · deef33c0
      Wei Chen authored
      [ Upstream commit 61ac4b86
      
       ]
      
      var->pixclock can be assigned to zero by user. Without proper
      check, divide by zero would occur in lx_set_clock.
      
      Error out if var->pixclock is zero.
      
      Signed-off-by: default avatarWei Chen <harperchen1110@gmail.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      deef33c0
    • Wei Chen's avatar
      fbdev: intelfb: Fix potential divide by zero · 4f5cc5ff
      Wei Chen authored
      [ Upstream commit d8236854
      
       ]
      
      Variable var->pixclock is controlled by user and can be assigned
      to zero. Without proper check, divide by zero would occur in
      intelfbhw_validate_mode and intelfbhw_mode_to_hw.
      
      Error out if var->pixclock is zero.
      
      Signed-off-by: default avatarWei Chen <harperchen1110@gmail.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f5cc5ff
    • Wei Chen's avatar
      fbdev: nvidia: Fix potential divide by zero · 868f247e
      Wei Chen authored
      [ Upstream commit 92e2a00f
      
       ]
      
      variable var->pixclock can be set by user. In case it
      equals to zero, divide by zero would occur in nvidiafb_set_par.
      
      Similar crashes have happened in other fbdev drivers. There
      is no check and modification on var->pixclock along the call
      chain to nvidia_check_var and nvidiafb_set_par. We believe it
      could also be triggered in driver nvidia from user site.
      
      Signed-off-by: default avatarWei Chen <harperchen1110@gmail.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      868f247e
    • Linus Torvalds's avatar
      sched_getaffinity: don't assume 'cpumask_size()' is fully initialized · f3359f5f
      Linus Torvalds authored
      [ Upstream commit 6015b1ac
      
       ]
      
      The getaffinity() system call uses 'cpumask_size()' to decide how big
      the CPU mask is - so far so good.  It is indeed the allocation size of a
      cpumask.
      
      But the code also assumes that the whole allocation is initialized
      without actually doing so itself.  That's wrong, because we might have
      fixed-size allocations (making copying and clearing more efficient), but
      not all of it is then necessarily used if 'nr_cpu_ids' is smaller.
      
      Having checked other users of 'cpumask_size()', they all seem to be ok,
      either using it purely for the allocation size, or explicitly zeroing
      the cpumask before using the size in bytes to copy it.
      
      See for example the ublk_ctrl_get_queue_affinity() function that uses
      the proper 'zalloc_cpumask_var()' to make sure that the whole mask is
      cleared, whether the storage is on the stack or if it was an external
      allocation.
      
      Fix this by just zeroing the allocation before using it.  Do the same
      for the compat version of sched_getaffinity(), which had the same logic.
      
      Also, for consistency, make sched_getaffinity() use 'cpumask_bits()' to
      access the bits.  For a cpumask_var_t, it ends up being a pointer to the
      same data either way, but it's just a good idea to treat it like you
      would a 'cpumask_t'.  The compat case already did that.
      
      Reported-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Link: https://lore.kernel.org/lkml/7d026744-6bd6-6827-0471-b5e8eae0be3f@arm.com/
      
      
      Cc: Yury Norov <yury.norov@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f3359f5f