Skip to content
  1. Nov 29, 2023
    • Greg Kroah-Hartman's avatar
      Linux 4.19.300 · 979b2ade
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20231124171934.122298957@linuxfoundation.org
      Link: https://lore.kernel.org/r/20231125163104.203147306@linuxfoundation.org
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Link: https://lore.kernel.org/r/20231126154323.146332656@linuxfoundation.org
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.19.300
      979b2ade
    • Eric Dumazet's avatar
      net: sched: fix race condition in qdisc_graft() · f782929b
      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>
      [ mheyne: removed rtnl_dereference due to missing commit 5891cd5e
      
      
        ("net_sched: add __rcu annotation to netdev->qdisc") ]
      Signed-off-by: default avatarMaximilian Heyne <mheyne@amazon.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f782929b
    • Matthew Wilcox (Oracle)'s avatar
      iomap: Set all uptodate bits for an Uptodate page · 0cf55444
      Matthew Wilcox (Oracle) authored
      commit 4595a298 upstream.
      
      For filesystems with block size < page size, we need to set all the
      per-block uptodate bits if the page was already uptodate at the time
      we create the per-block metadata.  This can happen if the page is
      invalidated (eg by a write to drop_caches) but ultimately not removed
      from the page cache.
      
      This is a data corruption issue as page writeback skips blocks which
      are marked !uptodate.
      
      Fixes: 9dc55f13
      
       ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reported-by: default avatarQian Cai <cai@redhat.com>
      Cc: Brian Foster <bfoster@redhat.com>
      Reviewed-by: default avatarGao Xiang <hsiangkao@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarShida Zhang <zhangshida@kylinos.cn>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0cf55444
    • Dongli Zhang's avatar
      scsi: virtio_scsi: limit number of hw queues by nr_cpu_ids · 7907729c
      Dongli Zhang authored
      commit 1978f30a
      
       upstream.
      
      When tag_set->nr_maps is 1, the block layer limits the number of hw queues
      by nr_cpu_ids. No matter how many hw queues are used by virtio-scsi, as it
      has (tag_set->nr_maps == 1), it can use at most nr_cpu_ids hw queues.
      
      In addition, specifically for pci scenario, when the 'num_queues' specified
      by qemu is more than maxcpus, virtio-scsi would not be able to allocate
      more than maxcpus vectors in order to have a vector for each queue. As a
      result, it falls back into MSI-X with one vector for config and one shared
      for queues.
      
      Considering above reasons, this patch limits the number of hw queues used
      by virtio-scsi by nr_cpu_ids.
      
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarDongli Zhang <dongli.zhang@oracle.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarKunkun Jiang <jiangkunkun@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7907729c
    • Christian König's avatar
      drm/amdgpu: fix error handling in amdgpu_bo_list_get() · b952a09c
      Christian König authored
      commit 12f76050
      
       upstream.
      
      We should not leak the pointer where we couldn't grab the reference
      on to the caller because it can be that the error handling still
      tries to put the reference then.
      
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b952a09c
    • Kemeng Shi's avatar
      ext4: remove gdb backup copy for meta bg in setup_new_flex_group_blocks · e9cafc68
      Kemeng Shi authored
      commit 40dd7953
      
       upstream.
      
      Wrong check of gdb backup in meta bg as following:
      first_group is the first group of meta_bg which contains target group, so
      target group is always >= first_group. We check if target group has gdb
      backup by comparing first_group with [group + 1] and [group +
      EXT4_DESC_PER_BLOCK(sb) - 1]. As group >= first_group, then [group + N] is
      > first_group. So no copy of gdb backup in meta bg is done in
      setup_new_flex_group_blocks.
      
      No need to do gdb backup copy in meta bg from setup_new_flex_group_blocks
      as we always copy updated gdb block to backups at end of
      ext4_flex_group_add as following:
      
      ext4_flex_group_add
        /* no gdb backup copy for meta bg any more */
        setup_new_flex_group_blocks
      
        /* update current group number */
        ext4_update_super
          sbi->s_groups_count += flex_gd->count;
      
        /*
         * if group in meta bg contains backup is added, the primary gdb block
         * of the meta bg will be copy to backup in new added group here.
         */
        for (; gdb_num <= gdb_num_end; gdb_num++)
          update_backups(...)
      
      In summary, we can remove wrong gdb backup copy code in
      setup_new_flex_group_blocks.
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Reviewed-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20230826174712.4059355-5-shikemeng@huaweicloud.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9cafc68
    • Kemeng Shi's avatar
      ext4: correct return value of ext4_convert_meta_bg · 5f209e49
      Kemeng Shi authored
      commit 48f15515
      
       upstream.
      
      Avoid to ignore error in "err".
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Link: https://lore.kernel.org/r/20230826174712.4059355-4-shikemeng@huaweicloud.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5f209e49
    • Kemeng Shi's avatar
      ext4: correct offset of gdb backup in non meta_bg group to update_backups · 8fceeaed
      Kemeng Shi authored
      commit 31f13421 upstream.
      
      Commit 0aeaa255
      
       ("ext4: fix corruption when online resizing a 1K
      bigalloc fs") found that primary superblock's offset in its group is
      not equal to offset of backup superblock in its group when block size
      is 1K and bigalloc is enabled. As group descriptor blocks are right
      after superblock, we can't pass block number of gdb to update_backups
      for the same reason.
      
      The root casue of the issue above is that leading 1K padding block is
      count as data block offset for primary block while backup block has no
      padding block offset in its group.
      
      Remove padding data block count to fix the issue for gdb backups.
      
      For meta_bg case, update_backups treat blk_off as block number, do no
      conversion in this case.
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Reviewed-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20230826174712.4059355-2-shikemeng@huaweicloud.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8fceeaed
    • Max Kellermann's avatar
      ext4: apply umask if ACL support is disabled · 80c85dec
      Max Kellermann authored
      commit 484fd6c1
      
       upstream.
      
      The function ext4_init_acl() calls posix_acl_create() which is
      responsible for applying the umask.  But without
      CONFIG_EXT4_FS_POSIX_ACL, ext4_init_acl() is an empty inline function,
      and nobody applies the umask.
      
      This fixes a bug which causes the umask to be ignored with O_TMPFILE
      on ext4:
      
       https://github.com/MusicPlayerDaemon/MPD/issues/558
       https://bugs.gentoo.org/show_bug.cgi?id=686142#c3
       https://bugzilla.kernel.org/show_bug.cgi?id=203625
      
      Reviewed-by: default avatar"J. Bruce Fields" <bfields@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Kellermann <max.kellermann@ionos.com>
      Link: https://lore.kernel.org/r/20230919081824.1096619-1-max.kellermann@ionos.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80c85dec
    • Heiner Kallweit's avatar
      Revert "net: r8169: Disable multicast filter for RTL8168H and RTL8107E" · ff442ca5
      Heiner Kallweit authored
      commit 6a263102 upstream.
      
      This reverts commit efa5f131
      
      .
      
      I couldn't reproduce the reported issue. What I did, based on a pcap
      packet log provided by the reporter:
      - Used same chip version (RTL8168h)
      - Set MAC address to the one used on the reporters system
      - Replayed the EAPOL unicast packet that, according to the reporter,
        was filtered out by the mc filter.
      The packet was properly received.
      
      Therefore the root cause of the reported issue seems to be somewhere
      else. Disabling mc filtering completely for the most common chip
      version is a quite big hammer. Therefore revert the change and wait
      for further analysis results from the reporter.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff442ca5
    • Vikash Garodia's avatar
      media: venus: hfi: add checks to handle capabilities from firmware · f784a9a8
      Vikash Garodia authored
      commit 8d0b8939 upstream.
      
      The hfi parser, parses the capabilities received from venus firmware and
      copies them to core capabilities. Consider below api, for example,
      fill_caps - In this api, caps in core structure gets updated with the
      number of capabilities received in firmware data payload. If the same api
      is called multiple times, there is a possibility of copying beyond the max
      allocated size in core caps.
      Similar possibilities in fill_raw_fmts and fill_profile_level functions.
      
      Cc: stable@vger.kernel.org
      Fixes: 1a73374a
      
       ("media: venus: hfi_parser: add common capability parser")
      Signed-off-by: default avatarVikash Garodia <quic_vgarodia@quicinc.com>
      Signed-off-by: default avatarStanimir Varbanov <stanimir.k.varbanov@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f784a9a8
    • Vikash Garodia's avatar
      media: venus: hfi: fix the check to handle session buffer requirement · c5223e87
      Vikash Garodia authored
      commit b18e36df upstream.
      
      Buffer requirement, for different buffer type, comes from video firmware.
      While copying these requirements, there is an OOB possibility when the
      payload from firmware is more than expected size. Fix the check to avoid
      the OOB possibility.
      
      Cc: stable@vger.kernel.org
      Fixes: 09c2845e
      
       ("[media] media: venus: hfi: add Host Firmware Interface (HFI)")
      Reviewed-by: default avatarNathan Hebert <nhebert@chromium.org>
      Signed-off-by: default avatarVikash Garodia <quic_vgarodia@quicinc.com>
      Signed-off-by: default avatarStanimir Varbanov <stanimir.k.varbanov@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c5223e87
    • Vikash Garodia's avatar
      media: venus: hfi_parser: Add check to keep the number of codecs within range · 4831e9f2
      Vikash Garodia authored
      commit 0768a9dd upstream.
      
      Supported codec bitmask is populated from the payload from venus firmware.
      There is a possible case when all the bits in the codec bitmask is set. In
      such case, core cap for decoder is filled  and MAX_CODEC_NUM is utilized.
      Now while filling the caps for encoder, it can lead to access the caps
      array beyong 32 index. Hence leading to OOB write.
      The fix counts the supported encoder and decoder. If the count is more than
      max, then it skips accessing the caps.
      
      Cc: stable@vger.kernel.org
      Fixes: 1a73374a
      
       ("media: venus: hfi_parser: add common capability parser")
      Signed-off-by: default avatarVikash Garodia <quic_vgarodia@quicinc.com>
      Signed-off-by: default avatarStanimir Varbanov <stanimir.k.varbanov@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4831e9f2
    • Sean Young's avatar
      media: sharp: fix sharp encoding · 480058cf
      Sean Young authored
      commit 4f7efc71 upstream.
      
      The Sharp protocol[1] encoding has incorrect timings for bit space.
      
      [1] https://www.sbprojects.net/knowledge/ir/sharp.php
      
      Fixes: d35afc5f
      
       ("[media] rc: ir-sharp-decoder: Add encode capability")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarJoe Ferner <joe.m.ferner@gmail.com>
      Closes: https://sourceforge.net/p/lirc/mailman/message/38604507/
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      480058cf
    • Sean Young's avatar
      media: lirc: drop trailing space from scancode transmit · 89287f95
      Sean Young authored
      commit c8a489f8 upstream.
      
      When transmitting, infrared drivers expect an odd number of samples; iow
      without a trailing space. No problems have been observed so far, so
      this is just belt and braces.
      
      Fixes: 9b619258
      
       ("media: lirc: implement scancode sending")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89287f95
    • Heiner Kallweit's avatar
      i2c: i801: fix potential race in i801_block_transaction_byte_by_byte · dff1af8f
      Heiner Kallweit authored
      commit f78ca48a
      
       upstream.
      
      Currently we set SMBHSTCNT_LAST_BYTE only after the host has started
      receiving the last byte. If we get e.g. preempted before setting
      SMBHSTCNT_LAST_BYTE, the host may be finished with receiving the byte
      before SMBHSTCNT_LAST_BYTE is set.
      Therefore change the code to set SMBHSTCNT_LAST_BYTE before writing
      SMBHSTSTS_BYTE_DONE for the byte before the last byte. Now the code
      is also consistent with what we do in i801_isr_byte_done().
      
      Reported-by: default avatarJean Delvare <jdelvare@suse.com>
      Closes: https://lore.kernel.org/linux-i2c/20230828152747.09444625@endymion.delvare/
      Cc: stable@vger.kernel.org
      Acked-by: default avatarAndi Shyti <andi.shyti@kernel.org>
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dff1af8f
    • Alexander Sverdlin's avatar
      net: dsa: lan9303: consequently nested-lock physical MDIO · 3f1b7cf0
      Alexander Sverdlin authored
      commit 5a22fbcc upstream.
      
      When LAN9303 is MDIO-connected two callchains exist into
      mdio->bus->write():
      
      1. switch ports 1&2 ("physical" PHYs):
      
      virtual (switch-internal) MDIO bus (lan9303_switch_ops->phy_{read|write})->
        lan9303_mdio_phy_{read|write} -> mdiobus_{read|write}_nested
      
      2. LAN9303 virtual PHY:
      
      virtual MDIO bus (lan9303_phy_{read|write}) ->
        lan9303_virt_phy_reg_{read|write} -> regmap -> lan9303_mdio_{read|write}
      
      If the latter functions just take
      mutex_lock(&sw_dev->device->bus->mdio_lock) it triggers a LOCKDEP
      false-positive splat. It's false-positive because the first
      mdio_lock in the second callchain above belongs to virtual MDIO bus, the
      second mdio_lock belongs to physical MDIO bus.
      
      Consequent annotation in lan9303_mdio_{read|write} as nested lock
      (similar to lan9303_mdio_phy_{read|write}, it's the same physical MDIO bus)
      prevents the following splat:
      
      WARNING: possible circular locking dependency detected
      5.15.71 #1 Not tainted
      ------------------------------------------------------
      kworker/u4:3/609 is trying to acquire lock:
      ffff000011531c68 (lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock){+.+.}-{3:3}, at: regmap_lock_mutex
      but task is already holding lock:
      ffff0000114c44d8 (&bus->mdio_lock){+.+.}-{3:3}, at: mdiobus_read
      which lock already depends on the new lock.
      the existing dependency chain (in reverse order) is:
      -> #1 (&bus->mdio_lock){+.+.}-{3:3}:
             lock_acquire
             __mutex_lock
             mutex_lock_nested
             lan9303_mdio_read
             _regmap_read
             regmap_read
             lan9303_probe
             lan9303_mdio_probe
             mdio_probe
             really_probe
             __driver_probe_device
             driver_probe_device
             __device_attach_driver
             bus_for_each_drv
             __device_attach
             device_initial_probe
             bus_probe_device
             deferred_probe_work_func
             process_one_work
             worker_thread
             kthread
             ret_from_fork
      -> #0 (lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock){+.+.}-{3:3}:
             __lock_acquire
             lock_acquire.part.0
             lock_acquire
             __mutex_lock
             mutex_lock_nested
             regmap_lock_mutex
             regmap_read
             lan9303_phy_read
             dsa_slave_phy_read
             __mdiobus_read
             mdiobus_read
             get_phy_device
             mdiobus_scan
             __mdiobus_register
             dsa_register_switch
             lan9303_probe
             lan9303_mdio_probe
             mdio_probe
             really_probe
             __driver_probe_device
             driver_probe_device
             __device_attach_driver
             bus_for_each_drv
             __device_attach
             device_initial_probe
             bus_probe_device
             deferred_probe_work_func
             process_one_work
             worker_thread
             kthread
             ret_from_fork
      other info that might help us debug this:
       Possible unsafe locking scenario:
             CPU0                    CPU1
             ----                    ----
        lock(&bus->mdio_lock);
                                     lock(lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock);
                                     lock(&bus->mdio_lock);
        lock(lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock);
      *** DEADLOCK ***
      5 locks held by kworker/u4:3/609:
       #0: ffff000002842938 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work
       #1: ffff80000bacbd60 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work
       #2: ffff000007645178 (&dev->mutex){....}-{3:3}, at: __device_attach
       #3: ffff8000096e6e78 (dsa2_mutex){+.+.}-{3:3}, at: dsa_register_switch
       #4: ffff0000114c44d8 (&bus->mdio_lock){+.+.}-{3:3}, at: mdiobus_read
      stack backtrace:
      CPU: 1 PID: 609 Comm: kworker/u4:3 Not tainted 5.15.71 #1
      Workqueue: events_unbound deferred_probe_work_func
      Call trace:
       dump_backtrace
       show_stack
       dump_stack_lvl
       dump_stack
       print_circular_bug
       check_noncircular
       __lock_acquire
       lock_acquire.part.0
       lock_acquire
       __mutex_lock
       mutex_lock_nested
       regmap_lock_mutex
       regmap_read
       lan9303_phy_read
       dsa_slave_phy_read
       __mdiobus_read
       mdiobus_read
       get_phy_device
       mdiobus_scan
       __mdiobus_register
       dsa_register_switch
       lan9303_probe
       lan9303_mdio_probe
      ...
      
      Cc: stable@vger.kernel.org
      Fixes: dc700583
      
       ("net: dsa: LAN9303: add MDIO managed mode support")
      Signed-off-by: default avatarAlexander Sverdlin <alexander.sverdlin@siemens.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20231027065741.534971-1-alexander.sverdlin@siemens.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f1b7cf0
    • Pavel Krasavin's avatar
      tty: serial: meson: fix hard LOCKUP on crtscts mode · c131b215
      Pavel Krasavin authored
      [ Upstream commit 2a1d728f ]
      
      There might be hard lockup if we set crtscts mode on port without RTS/CTS configured:
      
      # stty -F /dev/ttyAML6 crtscts; echo 1 > /dev/ttyAML6; echo 2 > /dev/ttyAML6
      [   95.890386] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
      [   95.890857] rcu:     3-...0: (201 ticks this GP) idle=e33c/1/0x4000000000000000 softirq=5844/5846 fqs=4984
      [   95.900212] rcu:     (detected by 2, t=21016 jiffies, g=7753, q=296 ncpus=4)
      [   95.906972] Task dump for CPU 3:
      [   95.910178] task:bash            state:R  running task     stack:0     pid:205   ppid:1      flags:0x00000202
      [   95.920059] Call trace:
      [   95.922485]  __switch_to+0xe4/0x168
      [   95.925951]  0xffffff8003477508
      [   95.974379] watchdog: Watchdog detected hard LOCKUP on cpu 3
      [   95.974424] Modules linked in: 88x2cs(O) rtc_meson_vrtc
      
      Possible solution would be to not allow to setup crtscts on such port.
      
      Tested on S905X3 based board.
      
      Fixes: ff7693d0
      
       ("ARM: meson: serial: add MesonX SoC on-chip uart driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPavel Krasavin <pkrasavin@imaqliq.com>
      Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
      Reviewed-by: default avatarDmitry Rokosov <ddrokosov@salutedevices.com>
      
      v6: stable tag added
      v5: https://lore.kernel.org/lkml/OF43DA36FF.2BD3BB21-ON00258A47.005A8125-00258A47.005A9513@gdc.ru/
      added missed Reviewed-by tags, Fixes tag added according to Dmitry and Neil notes
      v4: https://lore.kernel.org/lkml/OF55521400.7512350F-ON00258A47.003F7254-00258A47.0040E15C@gdc.ru/
      More correct patch subject according to Jiri's note
      v3: https://lore.kernel.org/lkml/OF6CF5FFA0.CCFD0E8E-ON00258A46.00549EDF-00258A46.0054BB62@gdc.ru/
      "From:" line added to the mail
      v2: https://lore.kernel.org/lkml/OF950BEF72.7F425944-ON00258A46.00488A76-00258A46.00497D44@gdc.ru/
      braces for single statement removed according to Dmitry's note
      v1: https://lore.kernel.org/lkml/OF28B2B8C9.5BC0CD28-ON00258A46.0037688F-00258A46.0039155B@gdc.ru/
      Link: https://lore.kernel.org/r/OF66360032.51C36182-ON00258A48.003F656B-00258A48.0040092C@gdc.ru
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c131b215
    • Lad Prabhakar's avatar
      serial: meson: Use platform_get_irq() to get the interrupt · 62fdc814
      Lad Prabhakar authored
      [ Upstream commit 5b680619
      
       ]
      
      platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
      allocation of IRQ resources in DT core code, this causes an issue
      when using hierarchical interrupt domains using "interrupts" property
      in the node as this bypasses the hierarchical setup and messes up the
      irq chaining.
      
      In preparation for removal of static setup of IRQ resource from DT core
      code use platform_get_irq().
      
      Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
      Link: https://lore.kernel.org/r/20211224142917.6966-5-prabhakar.mahadev-lad.rj@bp.renesas.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Stable-dep-of: 2a1d728f
      
       ("tty: serial: meson: fix hard LOCKUP on crtscts mode")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      62fdc814
    • Neil Armstrong's avatar
      tty: serial: meson: retrieve port FIFO size from DT · 9eb54dea
      Neil Armstrong authored
      [ Upstream commit 27d44e05
      
       ]
      
      Now the DT bindings has a property to get the FIFO size for a particular port,
      retrieve it and use to setup the FIFO interrupts threshold.
      
      Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Link: https://lore.kernel.org/r/20210518075833.3736038-3-narmstrong@baylibre.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Stable-dep-of: 2a1d728f
      
       ("tty: serial: meson: fix hard LOCKUP on crtscts mode")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9eb54dea
    • Colin Ian King's avatar
      serial: meson: remove redundant initialization of variable id · 60a0f56f
      Colin Ian King authored
      [ Upstream commit 021212f5
      
       ]
      
      The variable id being initialized with a value that is never read
      and it is being updated later with a new value. The initialization is
      redundant and can be removed. Since id is just being used in a for-loop
      inside a local scope, move the declaration of id to that scope.
      
      Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
      Reviewed-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Addresses-Coverity: ("Unused value")
      Link: https://lore.kernel.org/r/20210426101106.9122-1-colin.king@canonical.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Stable-dep-of: 2a1d728f
      
       ("tty: serial: meson: fix hard LOCKUP on crtscts mode")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      60a0f56f
    • Loys Ollivier's avatar
      tty: serial: meson: if no alias specified use an available id · eb9d94bd
      Loys Ollivier authored
      [ Upstream commit a26988e8
      
       ]
      
      At probe, the uart driver tries to get an id from a device tree alias.
      When no alias was specified, the driver would return an error and probing
      would fail.
      
      Providing an alias for registering a serial device should not be mandatory.
      If the device tree does not specify an alias, provide an id from a reserved
      range so that the probing can continue.
      
      Suggested-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarLoys Ollivier <lollivier@baylibre.com>
      Reviewed-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Stable-dep-of: 2a1d728f
      
       ("tty: serial: meson: fix hard LOCKUP on crtscts mode")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb9d94bd
    • Chandradeep Dey's avatar
      ALSA: hda/realtek - Enable internal speaker of ASUS K6500ZC · 65312da2
      Chandradeep Dey authored
      commit 713f040c
      
       upstream.
      
      Apply the already existing quirk chain ALC294_FIXUP_ASUS_SPK to enable
      the internal speaker of ASUS K6500ZC.
      
      Signed-off-by: default avatarChandradeep Dey <codesigning@chandradeepdey.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/NizcVHQ--3-9@chandradeepdey.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65312da2
    • Takashi Iwai's avatar
      ALSA: info: Fix potential deadlock at disconnection · 9f3d7b6a
      Takashi Iwai authored
      commit c7a60651
      
       upstream.
      
      As reported recently, ALSA core info helper may cause a deadlock at
      the forced device disconnection during the procfs operation.
      
      The proc_remove() (that is called from the snd_card_disconnect()
      helper) has a synchronization of the pending procfs accesses via
      wait_for_completion().  Meanwhile, ALSA procfs helper takes the global
      mutex_lock(&info_mutex) at both the proc_open callback and
      snd_card_info_disconnect() helper.  Since the proc_open can't finish
      due to the mutex lock, wait_for_completion() never returns, either,
      hence it deadlocks.
      
      	TASK#1				TASK#2
      	proc_reg_open()
      	  takes use_pde()
      	snd_info_text_entry_open()
      					snd_card_disconnect()
      					snd_info_card_disconnect()
      					  takes mutex_lock(&info_mutex)
      					proc_remove()
      					wait_for_completion(unused_pde)
      					  ... waiting task#1 closes
      	mutex_lock(&info_mutex)
      		=> DEADLOCK
      
      This patch is a workaround for avoiding the deadlock scenario above.
      
      The basic strategy is to move proc_remove() call outside the mutex
      lock.  proc_remove() can work gracefully without extra locking, and it
      can delete the tree recursively alone.  So, we call proc_remove() at
      snd_info_card_disconnection() at first, then delete the rest resources
      recursively within the info_mutex lock.
      
      After the change, the function snd_info_disconnect() doesn't do
      disconnection by itself any longer, but it merely clears the procfs
      pointer.  So rename the function to snd_info_clear_entries() for
      avoiding confusion.
      
      The similar change is applied to snd_info_free_entry(), too.  Since
      the proc_remove() is called only conditionally with the non-NULL
      entry->p, it's skipped after the snd_info_clear_entries() call.
      
      Reported-by: default avatarShinhyung Kang <s47.kang@samsung.com>
      Closes: https://lore.kernel.org/r/664457955.21699345385931.JavaMail.epsvc@epcpadp4
      Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20231109141954.4283-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f3d7b6a
    • Helge Deller's avatar
      parisc/pgtable: Do not drop upper 5 address bits of physical address · 4de42206
      Helge Deller authored
      commit 166b0110
      
       upstream.
      
      When calculating the pfn for the iitlbt/idtlbt instruction, do not
      drop the upper 5 address bits. This doesn't seem to have an effect
      on physical hardware which uses less physical address bits, but in
      qemu the missing bits are visible.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc:  <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4de42206
    • Helge Deller's avatar
      parisc: Prevent booting 64-bit kernels on PA1.x machines · 22733ddf
      Helge Deller authored
      commit a406b8b4
      
       upstream.
      
      Bail out early with error message when trying to boot a 64-bit kernel on
      32-bit machines. This fixes the previous commit to include the check for
      true 64-bit kernels as well.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Fixes: 591d2108
      
       ("parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines")
      Cc:  <stable@vger.kernel.org> # v6.0+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22733ddf
    • Alain Volmat's avatar
      dmaengine: stm32-mdma: correct desc prep when channel running · ed77f887
      Alain Volmat authored
      commit 03f25d53 upstream.
      
      In case of the prep descriptor while the channel is already running, the
      CCR register value stored into the channel could already have its EN bit
      set.  This would lead to a bad transfer since, at start transfer time,
      enabling the channel while other registers aren't yet properly set.
      To avoid this, ensure to mask the CCR_EN bit when storing the ccr value
      into the mdma channel structure.
      
      Fixes: a4ffb13c
      
       ("dmaengine: Add STM32 MDMA driver")
      Signed-off-by: default avatarAlain Volmat <alain.volmat@foss.st.com>
      Signed-off-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Cc: stable@vger.kernel.org
      Tested-by: default avatarAlain Volmat <alain.volmat@foss.st.com>
      Link: https://lore.kernel.org/r/20231009082450.452877-1-amelie.delaunay@foss.st.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed77f887
    • Sanjuán García, Jorge's avatar
      mcb: fix error handling for different scenarios when parsing · f1680f60
      Sanjuán García, Jorge authored
      commit 63ba2d07 upstream.
      
      chameleon_parse_gdd() may fail for different reasons and end up
      in the err tag. Make sure we at least always free the mcb_device
      allocated with mcb_alloc_dev().
      
      If mcb_device_register() fails, make sure to give up the reference
      in the same place the device was added.
      
      Fixes: 728ac338
      
       ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()")
      Cc: stable <stable@kernel.org>
      Reviewed-by: default avatarJose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
      Signed-off-by: default avatarJorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
      Link: https://lore.kernel.org/r/20231019141434.57971-2-jorge.sanjuangarcia@duagon.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1680f60
    • Eric Biggers's avatar
      quota: explicitly forbid quota files from being encrypted · bb814d22
      Eric Biggers authored
      commit d3cc1b0b upstream.
      
      Since commit d7e7b9af
      
       ("fscrypt: stop using keyrings subsystem for
      fscrypt_master_key"), xfstest generic/270 causes a WARNING when run on
      f2fs with test_dummy_encryption in the mount options:
      
      $ kvm-xfstests -c f2fs/encrypt generic/270
      [...]
      WARNING: CPU: 1 PID: 2453 at fs/crypto/keyring.c:240 fscrypt_destroy_keyring+0x1f5/0x260
      
      The cause of the WARNING is that not all encrypted inodes have been
      evicted before fscrypt_destroy_keyring() is called, which violates an
      assumption.  This happens because the test uses an external quota file,
      which gets automatically encrypted due to test_dummy_encryption.
      
      Encryption of quota files has never really been supported.  On ext4,
      ext4_quota_read() does not decrypt the data, so encrypted quota files
      are always considered invalid on ext4.  On f2fs, f2fs_quota_read() uses
      the pagecache, so trying to use an encrypted quota file gets farther,
      resulting in the issue described above being possible.  But this was
      never intended to be possible, and there is no use case for it.
      
      Therefore, make the quota support layer explicitly reject using
      IS_ENCRYPTED inodes when quotaon is attempted.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Message-Id: <20230905003227.326998-1-ebiggers@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb814d22
    • Zhihao Cheng's avatar
      jbd2: fix potential data lost in recovering journal raced with synchronizing fs bdev · 27952007
      Zhihao Cheng authored
      commit 61187fce
      
       upstream.
      
      JBD2 makes sure journal data is fallen on fs device by sync_blockdev(),
      however, other process could intercept the EIO information from bdev's
      mapping, which leads journal recovering successful even EIO occurs during
      data written back to fs device.
      
      We found this problem in our product, iscsi + multipath is chosen for block
      device of ext4. Unstable network may trigger kpartx to rescan partitions in
      device mapper layer. Detailed process is shown as following:
      
        mount          kpartx          irq
      jbd2_journal_recover
       do_one_pass
        memcpy(nbh->b_data, obh->b_data) // copy data to fs dev from journal
        mark_buffer_dirty // mark bh dirty
               vfs_read
      	  generic_file_read_iter // dio
      	   filemap_write_and_wait_range
      	    __filemap_fdatawrite_range
      	     do_writepages
      	      block_write_full_folio
      	       submit_bh_wbc
      	            >>  EIO occurs in disk  <<
      	                     end_buffer_async_write
      			      mark_buffer_write_io_error
      			       mapping_set_error
      			        set_bit(AS_EIO, &mapping->flags) // set!
      	    filemap_check_errors
      	     test_and_clear_bit(AS_EIO, &mapping->flags) // clear!
       err2 = sync_blockdev
        filemap_write_and_wait
         filemap_check_errors
          test_and_clear_bit(AS_EIO, &mapping->flags) // false
       err2 = 0
      
      Filesystem is mounted successfully even data from journal is failed written
      into disk, and ext4/ocfs2 could become corrupted.
      
      Fix it by comparing the wb_err state in fs block device before recovering
      and after recovering.
      
      A reproducer can be found in the kernel bugzilla referenced below.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=217888
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
      Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230919012525.1783108-1-chengzhihao1@huawei.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      27952007
    • Brian Geffon's avatar
      PM: hibernate: Clean up sync_read handling in snapshot_write_next() · 1e78a243
      Brian Geffon authored
      commit d08970df
      
       upstream.
      
      In snapshot_write_next(), sync_read is set and unset in three different
      spots unnecessiarly. As a result there is a subtle bug where the first
      page after the meta data has been loaded unconditionally sets sync_read
      to 0. If this first PFN was actually a highmem page, then the returned
      buffer will be the global "buffer," and the page needs to be loaded
      synchronously.
      
      That is, I'm not sure we can always assume the following to be safe:
      
      	handle->buffer = get_buffer(&orig_bm, &ca);
      	handle->sync_read = 0;
      
      Because get_buffer() can call get_highmem_page_buffer() which can
      return 'buffer'.
      
      The easiest way to address this is just set sync_read before
      snapshot_write_next() returns if handle->buffer == buffer.
      
      Signed-off-by: default avatarBrian Geffon <bgeffon@google.com>
      Fixes: 8357376d
      
       ("[PATCH] swsusp: Improve handling of highmem")
      Cc: All applicable <stable@vger.kernel.org>
      [ rjw: Subject and changelog edits ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1e78a243
    • Brian Geffon's avatar
      PM: hibernate: Use __get_safe_page() rather than touching the list · bda48834
      Brian Geffon authored
      commit f0c71830
      
       upstream.
      
      We found at least one situation where the safe pages list was empty and
      get_buffer() would gladly try to use a NULL pointer.
      
      Signed-off-by: default avatarBrian Geffon <bgeffon@google.com>
      Fixes: 8357376d
      
       ("[PATCH] swsusp: Improve handling of highmem")
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bda48834
    • Dan Carpenter's avatar
      mmc: vub300: fix an error code · 56203112
      Dan Carpenter authored
      commit b44f9da8 upstream.
      
      This error path should return -EINVAL instead of success.
      
      Fixes: 88095e7b
      
       ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/0769d30c-ad80-421b-bf5d-7d6f5d85604e@moroto.mountain
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56203112
    • Kathiravan Thirumoorthy's avatar
      clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks · 09d3a27e
      Kathiravan Thirumoorthy authored
      commit e641a070 upstream.
      
      GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based
      on the request from dependent clocks. Doing so will result in the
      unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL
      clocks.
      
      Cc: stable@vger.kernel.org
      Fixes: b8e7e519
      
       ("clk: qcom: ipq8074: add remaining PLL’s")
      Signed-off-by: default avatarKathiravan Thirumoorthy <quic_kathirav@quicinc.com>
      Link: https://lore.kernel.org/r/20230913-gpll_cleanup-v2-1-c8ceb1a37680@quicinc.com
      Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09d3a27e
    • Helge Deller's avatar
      parisc/pdc: Add width field to struct pdc_model · fdfdf8a7
      Helge Deller authored
      commit 6240553b
      
       upstream.
      
      PDC2.0 specifies the additional PSW-bit field.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdfdf8a7
    • Uwe Kleine-König's avatar
      PCI: keystone: Don't discard .probe() callback · f3770ee6
      Uwe Kleine-König authored
      commit 7994db90 upstream.
      
      The __init annotation makes the ks_pcie_probe() function disappear after
      booting completes. However a device can also be bound later. In that case,
      we try to call ks_pcie_probe(), but the backing memory is likely already
      overwritten.
      
      The right thing to do is do always have the probe callback available.  Note
      that the (wrong) __refdata annotation prevented this issue to be noticed by
      modpost.
      
      Fixes: 0c4ffcfe
      
       ("PCI: keystone: Add TI Keystone PCIe driver")
      Link: https://lore.kernel.org/r/20231001170254.2506508-5-u.kleine-koenig@pengutronix.de
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3770ee6
    • Uwe Kleine-König's avatar
      PCI: keystone: Don't discard .remove() callback · e203152b
      Uwe Kleine-König authored
      commit 200bddbb upstream.
      
      With CONFIG_PCIE_KEYSTONE=y and ks_pcie_remove() marked with __exit, the
      function is discarded from the driver. In this case a bound device can
      still get unbound, e.g via sysfs. Then no cleanup code is run resulting in
      resource leaks or worse.
      
      The right thing to do is do always have the remove callback available.
      Note that this driver cannot be compiled as a module, so ks_pcie_remove()
      was always discarded before this change and modpost couldn't warn about
      this issue. Furthermore the __ref annotation also prevents a warning.
      
      Fixes: 0c4ffcfe
      
       ("PCI: keystone: Add TI Keystone PCIe driver")
      Link: https://lore.kernel.org/r/20231001170254.2506508-4-u.kleine-koenig@pengutronix.de
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e203152b
    • Herve Codina's avatar
      genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware · 9188f47c
      Herve Codina authored
      commit 5e7afb2e upstream.
      
      irq_remove_generic_chip() calculates the Linux interrupt number for removing the
      handler and interrupt chip based on gc::irq_base as a linear function of
      the bit positions of set bits in the @msk argument.
      
      When the generic chip is present in an irq domain, i.e. created with a call
      to irq_alloc_domain_generic_chips(), gc::irq_base contains not the base
      Linux interrupt number.  It contains the base hardware interrupt for this
      chip. It is set to 0 for the first chip in the domain, 0 + N for the next
      chip, where $N is the number of hardware interrupts per chip.
      
      That means the Linux interrupt number cannot be calculated based on
      gc::irq_base for irqdomain based chips without a domain map lookup, which
      is currently missing.
      
      Rework the code to take the irqdomain case into account and calculate the
      Linux interrupt number by a irqdomain lookup of the domain specific
      hardware interrupt number.
      
      [ tglx: Massage changelog. Reshuffle the logic and add a proper comment. ]
      
      Fixes: cfefd21e
      
       ("genirq: Add chip suspend and resume callbacks")
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20231024150335.322282-1-herve.codina@bootlin.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9188f47c
    • Rong Chen's avatar
      mmc: meson-gx: Remove setting of CMD_CFG_ERROR · 4fa78ba0
      Rong Chen authored
      commit 57925e16 upstream.
      
      For the t7 and older SoC families, the CMD_CFG_ERROR has no effect.
      Starting from SoC family C3, setting this bit without SG LINK data
      address will cause the controller to generate an IRQ and stop working.
      
      To fix it, don't set the bit CMD_CFG_ERROR anymore.
      
      Fixes: 18f92bc0
      
       ("mmc: meson-gx: make sure the descriptor is stopped on errors")
      Signed-off-by: default avatarRong Chen <rong.chen@amlogic.com>
      Reviewed-by: default avatarJerome Brunet <jbrunet@baylibre.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20231026073156.2868310-1-rong.chen@amlogic.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fa78ba0
    • Lukas Wunner's avatar
      PCI/sysfs: Protect driver's D3cold preference from user space · 4ae7ca6b
      Lukas Wunner authored
      commit 70b70a43 upstream.
      
      struct pci_dev contains two flags which govern whether the device may
      suspend to D3cold:
      
      * no_d3cold provides an opt-out for drivers (e.g. if a device is known
        to not wake from D3cold)
      
      * d3cold_allowed provides an opt-out for user space (default is true,
        user space may set to false)
      
      Since commit 9d26d3a8 ("PCI: Put PCIe ports into D3 during suspend"),
      the user space setting overwrites the driver setting.  Essentially user
      space is trusted to know better than the driver whether D3cold is
      working.
      
      That feels unsafe and wrong.  Assume that the change was introduced
      inadvertently and do not overwrite no_d3cold when d3cold_allowed is
      modified.  Instead, consider d3cold_allowed in addition to no_d3cold
      when choosing a suspend state for the device.
      
      That way, user space may opt out of D3cold if the driver hasn't, but it
      may no longer force an opt in if the driver has opted out.
      
      Fixes: 9d26d3a8
      
       ("PCI: Put PCIe ports into D3 during suspend")
      Link: https://lore.kernel.org/r/b8a7f4af2b73f6b506ad8ddee59d747cbf834606.1695025365.git.lukas@wunner.de
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Cc: stable@vger.kernel.org	# v4.8+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ae7ca6b