Skip to content
  1. Nov 16, 2022
    • Peter Xu's avatar
      mm/shmem: use page_mapping() to detect page cache for uffd continue · c50396a8
      Peter Xu authored
      commit 93b0d917 upstream.
      
      mfill_atomic_install_pte() checks page->mapping to detect whether one page
      is used in the page cache.  However as pointed out by Matthew, the page
      can logically be a tail page rather than always the head in the case of
      uffd minor mode with UFFDIO_CONTINUE.  It means we could wrongly install
      one pte with shmem thp tail page assuming it's an anonymous page.
      
      It's not that clear even for anonymous page, since normally anonymous
      pages also have page->mapping being setup with the anon vma.  It's safe
      here only because the only such caller to mfill_atomic_install_pte() is
      always passing in a newly allocated page (mcopy_atomic_pte()), whose
      page->mapping is not yet setup.  However that's not extremely obvious
      either.
      
      For either of above, use page_mapping() instead.
      
      Link: https://lkml.kernel.org/r/Y2K+y7wnhC4vbnP2@x1n
      Fixes: 15313257
      
       ("userfaultfd/shmem: support UFFDIO_CONTINUE for shmem")
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Reported-by: default avatarMatthew Wilcox <willy@infradead.org>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Axel Rasmussen <axelrasmussen@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c50396a8
    • Pankaj Gupta's avatar
      mm/memremap.c: map FS_DAX device memory as decrypted · 83f89c90
      Pankaj Gupta authored
      commit 867400af upstream.
      
      virtio_pmem use devm_memremap_pages() to map the device memory.  By
      default this memory is mapped as encrypted with SEV.  Guest reboot changes
      the current encryption key and guest no longer properly decrypts the FSDAX
      device meta data.
      
      Mark the corresponding device memory region for FSDAX devices (mapped with
      memremap_pages) as decrypted to retain the persistent memory property.
      
      Link: https://lkml.kernel.org/r/20221102160728.3184016-1-pankaj.gupta@amd.com
      Fixes: b7b3c01b
      
       ("mm/memremap_pages: support multiple ranges per invocation")
      Signed-off-by: default avatarPankaj Gupta <pankaj.gupta@amd.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      83f89c90
    • SeongJae Park's avatar
      mm/damon/dbgfs: check if rm_contexts input is for a real context · 599e798e
      SeongJae Park authored
      commit 1de09a72 upstream.
      
      A user could write a name of a file under 'damon/' debugfs directory,
      which is not a user-created context, to 'rm_contexts' file.  In the case,
      'dbgfs_rm_context()' just assumes it's the valid DAMON context directory
      only if a file of the name exist.  As a result, invalid memory access
      could happen as below.  Fix the bug by checking if the given input is for
      a directory.  This check can filter out non-context inputs because
      directories under 'damon/' debugfs directory can be created via only
      'mk_contexts' file.
      
      This bug has found by syzbot[1].
      
      [1] https://lore.kernel.org/damon/000000000000ede3ac05ec4abf8e@google.com/
      
      Link: https://lkml.kernel.org/r/20221107165001.5717-2-sj@kernel.org
      Fixes: 75c1c2b5
      
       ("mm/damon/dbgfs: support multiple contexts")
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Reported-by: default avatar <syzbot+6087eafb76a94c4ac9eb@syzkaller.appspotmail.com>
      Cc: <stable@vger.kernel.org>	[5.15.x]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      599e798e
    • Fenghua Yu's avatar
      dmaengine: idxd: Do not enable user type Work Queue without Shared Virtual Addressing · 7eb5008a
      Fenghua Yu authored
      commit 0ec8ce07 upstream.
      
      When the idxd_user_drv driver is bound to a Work Queue (WQ) device
      without IOMMU or with IOMMU Passthrough without Shared Virtual
      Addressing (SVA), the application gains direct access to physical
      memory via the device by programming physical address to a submitted
      descriptor. This allows direct userspace read and write access to
      arbitrary physical memory. This is inconsistent with the security
      goals of a good kernel API.
      
      Unlike vfio_pci driver, the IDXD char device driver does not provide any
      ways to pin user pages and translate the address from user VA to IOVA or
      PA without IOMMU SVA. Therefore the application has no way to instruct the
      device to perform DMA function. This makes the char device not usable for
      normal application usage.
      
      Since user type WQ without SVA cannot be used for normal application usage
      and presents the security issue, bind idxd_user_drv driver and enable user
      type WQ only when SVA is enabled (i.e. user PASID is enabled).
      
      Fixes: 448c3de8
      
       ("dmaengine: idxd: create user driver for wq 'device'")
      Cc: stable@vger.kernel.org
      Suggested-by: default avatarArjan Van De Ven <arjan.van.de.ven@intel.com>
      Signed-off-by: default avatarFenghua Yu <fenghua.yu@intel.com>
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Reviewed-by: default avatarJerry Snitselaar <jsnitsel@redhat.com>
      Link: https://lore.kernel.org/r/20221014222541.3912195-1-fenghua.yu@intel.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7eb5008a
    • Vasily Gorbik's avatar
      mm: hugetlb_vmemmap: include missing linux/moduleparam.h · d51c525d
      Vasily Gorbik authored
      commit db5e8d84 upstream.
      
      The kernel test robot reported build failures with a 'randconfig' on s390:
      >> mm/hugetlb_vmemmap.c:421:11: error: a function declaration without a
      prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
         core_param(hugetlb_free_vmemmap, vmemmap_optimize_enabled, bool, 0);
                   ^
      
      Link: https://lore.kernel.org/linux-mm/202210300751.rG3UDsuc-lkp@intel.com/
      Link: https://lkml.kernel.org/r/patch.git-296b83ca939b.your-ad-here.call-01667411912-ext-5073@work.hours
      Fixes: 30152245
      
       ("mm: hugetlb_vmemmap: replace early_param() with core_param()")
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d51c525d
    • Naoya Horiguchi's avatar
      arch/x86/mm/hugetlbpage.c: pud_huge() returns 0 when using 2-level paging · bccc10be
      Naoya Horiguchi authored
      commit 1fdbed65 upstream.
      
      The following bug is reported to be triggered when starting X on x86-32
      system with i915:
      
        [  225.777375] kernel BUG at mm/memory.c:2664!
        [  225.777391] invalid opcode: 0000 [#1] PREEMPT SMP
        [  225.777405] CPU: 0 PID: 2402 Comm: Xorg Not tainted 6.1.0-rc3-bdg+ #86
        [  225.777415] Hardware name:  /8I865G775-G, BIOS F1 08/29/2006
        [  225.777421] EIP: __apply_to_page_range+0x24d/0x31c
        [  225.777437] Code: ff ff 8b 55 e8 8b 45 cc e8 0a 11 ec ff 89 d8 83 c4 28 5b 5e 5f 5d c3 81 7d e0 a0 ef 96 c1 74 ad 8b 45 d0 e8 2d 83 49 00 eb a3 <0f> 0b 25 00 f0 ff ff 81 eb 00 00 00 40 01 c3 8b 45 ec 8b 00 e8 76
        [  225.777446] EAX: 00000001 EBX: c53a3b58 ECX: b5c00000 EDX: c258aa00
        [  225.777454] ESI: b5c00000 EDI: b5900000 EBP: c4b0fdb4 ESP: c4b0fd80
        [  225.777462] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 EFLAGS: 00010202
        [  225.777470] CR0: 80050033 CR2: b5900000 CR3: 053a3000 CR4: 000006d0
        [  225.777479] Call Trace:
        [  225.777486]  ? i915_memcpy_init_early+0x63/0x63 [i915]
        [  225.777684]  apply_to_page_range+0x21/0x27
        [  225.777694]  ? i915_memcpy_init_early+0x63/0x63 [i915]
        [  225.777870]  remap_io_mapping+0x49/0x75 [i915]
        [  225.778046]  ? i915_memcpy_init_early+0x63/0x63 [i915]
        [  225.778220]  ? mutex_unlock+0xb/0xd
        [  225.778231]  ? i915_vma_pin_fence+0x6d/0xf7 [i915]
        [  225.778420]  vm_fault_gtt+0x2a9/0x8f1 [i915]
        [  225.778644]  ? lock_is_held_type+0x56/0xe7
        [  225.778655]  ? lock_is_held_type+0x7a/0xe7
        [  225.778663]  ? 0xc1000000
        [  225.778670]  __do_fault+0x21/0x6a
        [  225.778679]  handle_mm_fault+0x708/0xb21
        [  225.778686]  ? mt_find+0x21e/0x5ae
        [  225.778696]  exc_page_fault+0x185/0x705
        [  225.778704]  ? doublefault_shim+0x127/0x127
        [  225.778715]  handle_exception+0x130/0x130
        [  225.778723] EIP: 0xb700468a
      
      Recently pud_huge() got aware of non-present entry by commit 3a194f3f
      ("mm/hugetlb: make pud_huge() and follow_huge_pud() aware of non-present
      pud entry") to handle some special states of gigantic page.  However, it's
      overlooked that pud_none() always returns false when running with 2-level
      paging, and as a result pud_huge() can return true pointlessly.
      
      Introduce "#if CONFIG_PGTABLE_LEVELS > 2" to pud_huge() to deal with this.
      
      Link: https://lkml.kernel.org/r/20221107021010.2449306-1-naoya.horiguchi@linux.dev
      Fixes: 3a194f3f
      
       ("mm/hugetlb: make pud_huge() and follow_huge_pud() aware of non-present pud entry")
      Signed-off-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Reported-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Tested-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Liu Shixin <liushixin2@huawei.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: Yang Shi <shy828301@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bccc10be
    • Mika Westerberg's avatar
      spi: intel: Use correct mask for flash and protected regions · eaa40230
      Mika Westerberg authored
      commit 92a66cbf
      
       upstream.
      
      The flash and protected region mask is actually 0x7fff (30:16 and 14:0)
      and not 0x3fff so fix this accordingly. While there use GENMASK() instead.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Link: https://lore.kernel.org/r/20221025062800.22357-1-mika.westerberg@linux.intel.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eaa40230
    • ZhangPeng's avatar
      udf: Fix a slab-out-of-bounds write bug in udf_find_entry() · ac79001b
      ZhangPeng authored
      commit c8af247d
      
       upstream.
      
      Syzbot reported a slab-out-of-bounds Write bug:
      
      loop0: detected capacity change from 0 to 2048
      ==================================================================
      BUG: KASAN: slab-out-of-bounds in udf_find_entry+0x8a5/0x14f0
      fs/udf/namei.c:253
      Write of size 105 at addr ffff8880123ff896 by task syz-executor323/3610
      
      CPU: 0 PID: 3610 Comm: syz-executor323 Not tainted
      6.1.0-rc2-syzkaller-00105-gb229b6ca5abb #0
      Hardware name: Google Compute Engine/Google Compute Engine, BIOS
      Google 10/11/2022
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
       print_address_description+0x74/0x340 mm/kasan/report.c:284
       print_report+0x107/0x1f0 mm/kasan/report.c:395
       kasan_report+0xcd/0x100 mm/kasan/report.c:495
       kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189
       memcpy+0x3c/0x60 mm/kasan/shadow.c:66
       udf_find_entry+0x8a5/0x14f0 fs/udf/namei.c:253
       udf_lookup+0xef/0x340 fs/udf/namei.c:309
       lookup_open fs/namei.c:3391 [inline]
       open_last_lookups fs/namei.c:3481 [inline]
       path_openat+0x10e6/0x2df0 fs/namei.c:3710
       do_filp_open+0x264/0x4f0 fs/namei.c:3740
       do_sys_openat2+0x124/0x4e0 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_creat fs/open.c:1402 [inline]
       __se_sys_creat fs/open.c:1396 [inline]
       __x64_sys_creat+0x11f/0x160 fs/open.c:1396
       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
      RIP: 0033:0x7ffab0d164d9
      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 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffe1a7e6bb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ffab0d164d9
      RDX: 00007ffab0d164d9 RSI: 0000000000000000 RDI: 0000000020000180
      RBP: 00007ffab0cd5a10 R08: 0000000000000000 R09: 0000000000000000
      R10: 00005555573552c0 R11: 0000000000000246 R12: 00007ffab0cd5aa0
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      Allocated by task 3610:
       kasan_save_stack mm/kasan/common.c:45 [inline]
       kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
       ____kasan_kmalloc mm/kasan/common.c:371 [inline]
       __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:380
       kmalloc include/linux/slab.h:576 [inline]
       udf_find_entry+0x7b6/0x14f0 fs/udf/namei.c:243
       udf_lookup+0xef/0x340 fs/udf/namei.c:309
       lookup_open fs/namei.c:3391 [inline]
       open_last_lookups fs/namei.c:3481 [inline]
       path_openat+0x10e6/0x2df0 fs/namei.c:3710
       do_filp_open+0x264/0x4f0 fs/namei.c:3740
       do_sys_openat2+0x124/0x4e0 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_creat fs/open.c:1402 [inline]
       __se_sys_creat fs/open.c:1396 [inline]
       __x64_sys_creat+0x11f/0x160 fs/open.c:1396
       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
      
      The buggy address belongs to the object at ffff8880123ff800
       which belongs to the cache kmalloc-256 of size 256
      The buggy address is located 150 bytes inside of
       256-byte region [ffff8880123ff800, ffff8880123ff900)
      
      The buggy address belongs to the physical page:
      page:ffffea000048ff80 refcount:1 mapcount:0 mapping:0000000000000000
      index:0x0 pfn:0x123fe
      head:ffffea000048ff80 order:1 compound_mapcount:0 compound_pincount:0
      flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
      raw: 00fff00000010200 ffffea00004b8500 dead000000000003 ffff888012041b40
      raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 0, migratetype Unmovable, gfp_mask 0x0(),
      pid 1, tgid 1 (swapper/0), ts 1841222404, free_ts 0
       create_dummy_stack mm/page_owner.c:67 [inline]
       register_early_stack+0x77/0xd0 mm/page_owner.c:83
       init_page_owner+0x3a/0x731 mm/page_owner.c:93
       kernel_init_freeable+0x41c/0x5d5 init/main.c:1629
       kernel_init+0x19/0x2b0 init/main.c:1519
      page_owner free stack trace missing
      
      Memory state around the buggy address:
       ffff8880123ff780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff8880123ff800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      >ffff8880123ff880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06
                                                                      ^
       ffff8880123ff900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff8880123ff980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      ==================================================================
      
      Fix this by changing the memory size allocated for copy_name from
      UDF_NAME_LEN(254) to UDF_NAME_LEN_CS0(255), because the total length
      (lfi) of subsequent memcpy can be up to 255.
      
      CC: stable@vger.kernel.org
      Reported-by: default avatar <syzbot+69c9fdccc6dd08961d34@syzkaller.appspotmail.com>
      Fixes: 066b9cde
      
       ("udf: Use separate buffer for copying split names")
      Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20221109013542.442790-1-zhangpeng362@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac79001b
    • Brian Norris's avatar
      mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI · cef34a85
      Brian Norris authored
      commit fb1dec44 upstream.
      
      [[ NOTE: this is completely untested by the author, but included solely
          because, as noted in commit df57d732 ("mmc: sdhci-pci: Fix
          SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
          drivers using CQHCI might benefit from a similar change, if they
          also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
          bug on at least MSM, Arasan, and Intel hardware. ]]
      
      SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
      tracking that properly in software. When out of sync, we may trigger
      various timeouts.
      
      It's not typical to perform resets while CQE is enabled, but this may
      occur in some suspend or error recovery scenarios.
      
      Include this fix by way of the new sdhci_and_cqhci_reset() helper.
      
      This patch depends on (and should not compile without) the patch
      entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
      CQHCI".
      
      Fixes: bb6e3581
      
       ("mmc: sdhci-esdhc-imx: add CMDQ support")
      Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
      Reviewed-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221026124150.v4.4.I7d01f9ad11bacdc9213dee61b7918982aea39115@changeid
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cef34a85
    • Roger Quadros's avatar
      net: ethernet: ti: am65-cpsw: Fix segmentation fault at module unload · 442fd1bf
      Roger Quadros authored
      commit 1a0c016a upstream.
      
      Move am65_cpsw_nuss_phylink_cleanup() call to after
      am65_cpsw_nuss_cleanup_ndev() so phylink is still valid
      to prevent the below Segmentation fault on module remove when
      first slave link is up.
      
      [   31.652944] Unable to handle kernel paging request at virtual address 00040008000005f4
      [   31.684627] Mem abort info:
      [   31.687446]   ESR = 0x0000000096000004
      [   31.704614]   EC = 0x25: DABT (current EL), IL = 32 bits
      [   31.720663]   SET = 0, FnV = 0
      [   31.723729]   EA = 0, S1PTW = 0
      [   31.740617]   FSC = 0x04: level 0 translation fault
      [   31.756624] Data abort info:
      [   31.759508]   ISV = 0, ISS = 0x00000004
      [   31.776705]   CM = 0, WnR = 0
      [   31.779695] [00040008000005f4] address between user and kernel address ranges
      [   31.808644] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
      [   31.814928] Modules linked in: wlcore_sdio wl18xx wlcore mac80211 libarc4 cfg80211 rfkill crct10dif_ce phy_gmii_sel ti_am65_cpsw_nuss(-) sch_fq_codel ipv6
      [   31.828776] CPU: 0 PID: 1026 Comm: modprobe Not tainted 6.1.0-rc2-00012-gfabfcf7dafdb-dirty #160
      [   31.837547] Hardware name: Texas Instruments AM625 (DT)
      [   31.842760] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [   31.849709] pc : phy_stop+0x18/0xf8
      [   31.853202] lr : phylink_stop+0x38/0xf8
      [   31.857031] sp : ffff80000a0839f0
      [   31.860335] x29: ffff80000a0839f0 x28: ffff000000de1c80 x27: 0000000000000000
      [   31.867462] x26: 0000000000000000 x25: 0000000000000000 x24: ffff80000a083b98
      [   31.874589] x23: 0000000000000800 x22: 0000000000000001 x21: ffff000001bfba90
      [   31.881715] x20: ffff0000015ee000 x19: 0004000800000200 x18: 0000000000000000
      [   31.888842] x17: ffff800076c45000 x16: ffff800008004000 x15: 000058e39660b106
      [   31.895969] x14: 0000000000000144 x13: 0000000000000144 x12: 0000000000000000
      [   31.903095] x11: 000000000000275f x10: 00000000000009e0 x9 : ffff80000a0837d0
      [   31.910222] x8 : ffff000000de26c0 x7 : ffff00007fbd6540 x6 : ffff00007fbd64c0
      [   31.917349] x5 : ffff00007fbd0b10 x4 : ffff00007fbd0b10 x3 : ffff00007fbd3920
      [   31.924476] x2 : d0a07fcff8b8d500 x1 : 0000000000000000 x0 : 0004000800000200
      [   31.931603] Call trace:
      [   31.934042]  phy_stop+0x18/0xf8
      [   31.937177]  phylink_stop+0x38/0xf8
      [   31.940657]  am65_cpsw_nuss_ndo_slave_stop+0x28/0x1e0 [ti_am65_cpsw_nuss]
      [   31.947452]  __dev_close_many+0xa4/0x140
      [   31.951371]  dev_close_many+0x84/0x128
      [   31.955115]  unregister_netdevice_many+0x130/0x6d0
      [   31.959897]  unregister_netdevice_queue+0x94/0xd8
      [   31.964591]  unregister_netdev+0x24/0x38
      [   31.968504]  am65_cpsw_nuss_cleanup_ndev.isra.0+0x48/0x70 [ti_am65_cpsw_nuss]
      [   31.975637]  am65_cpsw_nuss_remove+0x58/0xf8 [ti_am65_cpsw_nuss]
      
      Cc: <Stable@vger.kernel.org> # v5.18+
      Fixes: e8609e69
      
       ("net: ethernet: ti: am65-cpsw: Convert to PHYLINK")
      Signed-off-by: default avatarRoger Quadros <rogerq@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      442fd1bf
    • Johan Hovold's avatar
      phy: qcom-qmp-combo: fix NULL-deref on runtime resume · c559a8b5
      Johan Hovold authored
      commit 04948e75 upstream.
      
      Commit fc646236 ("phy: qcom-qmp-combo,usb: add support for separate
      PCS_USB region") started treating the PCS_USB registers as potentially
      separate from the PCS registers but used the wrong base when no PCS_USB
      offset has been provided.
      
      Fix the PCS_USB base used at runtime resume to prevent dereferencing a
      NULL pointer on platforms that do not provide a PCS_USB offset (e.g.
      SC7180).
      
      Fixes: fc646236
      
       ("phy: qcom-qmp-combo,usb: add support for separate PCS_USB region")
      Cc: stable@vger.kernel.org	# 5.20
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarAndrew Halaney <ahalaney@redhat.com>
      Link: https://lore.kernel.org/r/20221026162116.26462-1-johan+linaro@kernel.org
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c559a8b5
    • Jens Axboe's avatar
      io_uring: check for rollover of buffer ID when providing buffers · 93beea33
      Jens Axboe authored
      commit 3851d25c
      
       upstream.
      
      We already check if the chosen starting offset for the buffer IDs fit
      within an unsigned short, as 65535 is the maximum value for a provided
      buffer. But if the caller asks to add N buffers at offset M, and M + N
      would exceed the size of the unsigned short, we simply add buffers with
      wrapping around the ID.
      
      This is not necessarily a bug and could in fact be a valid use case, but
      it seems confusing and inconsistent with the initial check for starting
      offset. Let's check for wrap consistently, and error the addition if we
      do need to wrap.
      
      Reported-by: default avatarOlivier Langlois <olivier@trillion01.com>
      Link: https://github.com/axboe/liburing/issues/726
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93beea33
    • Johannes Thumshirn's avatar
      btrfs: zoned: initialize device's zone info for seeding · 544f38a7
      Johannes Thumshirn authored
      commit a8d1b164
      
       upstream.
      
      When performing seeding on a zoned filesystem it is necessary to
      initialize each zoned device's btrfs_zoned_device_info structure,
      otherwise mounting the filesystem will cause a NULL pointer dereference.
      
      This was uncovered by fstests' testcase btrfs/163.
      
      CC: stable@vger.kernel.org # 5.15+
      Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      544f38a7
    • Johannes Thumshirn's avatar
      btrfs: zoned: clone zoned device info when cloning a device · ad88cabc
      Johannes Thumshirn authored
      commit 21e61ec6
      
       upstream.
      
      When cloning a btrfs_device, we're not cloning the associated
      btrfs_zoned_device_info structure of the device in case of a zoned
      filesystem.
      
      Later on this leads to a NULL pointer dereference when accessing the
      device's zone_info for instance when setting a zone as active.
      
      This was uncovered by fstests' testcase btrfs/161.
      
      CC: stable@vger.kernel.org # 5.15+
      Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.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>
      ad88cabc
    • Zhang Xiaoxu's avatar
      btrfs: selftests: fix wrong error check in btrfs_free_dummy_root() · 455af64a
      Zhang Xiaoxu authored
      commit 9b2f2034 upstream.
      
      The btrfs_alloc_dummy_root() uses ERR_PTR as the error return value
      rather than NULL, if error happened, there will be a NULL pointer
      dereference:
      
        BUG: KASAN: null-ptr-deref in btrfs_free_dummy_root+0x21/0x50 [btrfs]
        Read of size 8 at addr 000000000000002c by task insmod/258926
      
        CPU: 2 PID: 258926 Comm: insmod Tainted: G        W          6.1.0-rc2+ #5
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014
        Call Trace:
         <TASK>
         dump_stack_lvl+0x34/0x44
         kasan_report+0xb7/0x140
         kasan_check_range+0x145/0x1a0
         btrfs_free_dummy_root+0x21/0x50 [btrfs]
         btrfs_test_free_space_cache+0x1a8c/0x1add [btrfs]
         btrfs_run_sanity_tests+0x65/0x80 [btrfs]
         init_btrfs_fs+0xec/0x154 [btrfs]
         do_one_initcall+0x87/0x2a0
         do_init_module+0xdf/0x320
         load_module+0x3006/0x3390
         __do_sys_finit_module+0x113/0x1b0
         do_syscall_64+0x35/0x80
       entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Fixes: aaedb55b
      
       ("Btrfs: add tests for btrfs_get_extent")
      CC: stable@vger.kernel.org # 4.9+
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.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>
      455af64a
    • Liu Shixin's avatar
      btrfs: fix match incorrectly in dev_args_match_device · bc6c127c
      Liu Shixin authored
      commit 0fca385d upstream.
      
      syzkaller found a failed assertion:
      
        assertion failed: (args->devid != (u64)-1) || args->missing, in fs/btrfs/volumes.c:6921
      
      This can be triggered when we set devid to (u64)-1 by ioctl. In this
      case, the match of devid will be skipped and the match of device may
      succeed incorrectly.
      
      Patch 562d7b15
      
       introduced this function which is used to match device.
      This function contains two matching scenarios, we can distinguish them by
      checking the value of args->missing rather than check whether args->devid
      and args->uuid is default value.
      
      Reported-by: default avatar <syzbot+031687116258450f9853@syzkaller.appspotmail.com>
      Fixes: 562d7b15
      
       ("btrfs: handle device lookup with btrfs_dev_lookup_args")
      CC: stable@vger.kernel.org # 5.16+
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc6c127c
    • Wen Gong's avatar
      wifi: ath11k: avoid deadlock during regulatory update in ath11k_regd_update() · c97b1209
      Wen Gong authored
      commit f45cb6b2 upstream.
      
      (cherry picked from commit d99884ad
      
       in ath-next
      as users are seeing this bug more now, also cc stable)
      
      Running this test in a loop it is easy to reproduce an rtnl deadlock:
      
      iw reg set FI
      ifconfig wlan0 down
      
      What happens is that thread A (workqueue) tries to update the regulatory:
      
          try to acquire the rtnl_lock of ar->regd_update_work
      
          rtnl_lock+0x17/0x20
          ath11k_regd_update+0x15a/0x260 [ath11k]
          ath11k_regd_update_work+0x15/0x20 [ath11k]
          process_one_work+0x228/0x670
          worker_thread+0x4d/0x440
          kthread+0x16d/0x1b0
          ret_from_fork+0x22/0x30
      
      And thread B (ifconfig) tries to stop the interface:
      
          try to cancel_work_sync(&ar->regd_update_work) in ath11k_mac_op_stop().
          ifconfig  3109 [003]  2414.232506: probe:
      
          ath11k_mac_op_stop: (ffffffffc14187a0)
          drv_stop+0x30 ([mac80211])
          ieee80211_do_stop+0x5d2 ([mac80211])
          ieee80211_stop+0x3e ([mac80211])
          __dev_close_many+0x9e ([kernel.kallsyms])
          __dev_change_flags+0xbe ([kernel.kallsyms])
          dev_change_flags+0x23 ([kernel.kallsyms])
          devinet_ioctl+0x5e3 ([kernel.kallsyms])
          inet_ioctl+0x197 ([kernel.kallsyms])
          sock_do_ioctl+0x4d ([kernel.kallsyms])
          sock_ioctl+0x264 ([kernel.kallsyms])
          __x64_sys_ioctl+0x92 ([kernel.kallsyms])
          do_syscall_64+0x3a ([kernel.kallsyms])
          entry_SYSCALL_64_after_hwframe+0x63 ([kernel.kallsyms])
          __GI___ioctl+0x7 (/lib/x86_64-linux-gnu/libc-2.23.so)
      
      The sequence of deadlock is:
      
      1. Thread B calls rtnl_lock().
      
      2. Thread A starts to run and calls rtnl_lock() from within
         ath11k_regd_update_work(), then enters wait state because the lock is owned by
         thread B.
      
      3. Thread B continues to run and tries to call
         cancel_work_sync(&ar->regd_update_work), but thread A is in
         ath11k_regd_update_work() waiting for rtnl_lock(). So cancel_work_sync()
         forever waits for ath11k_regd_update_work() to finish and we have a deadlock.
      
      Fix this by switching from using regulatory_set_wiphy_regd_sync() to
      regulatory_set_wiphy_regd(). Now cfg80211 will schedule another workqueue which
      handles the locking on it's own. So the ath11k workqueue can simply exit without
      taking any locks, avoiding the deadlock.
      
      Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarWen Gong <quic_wgong@quicinc.com>
      [kvalo: improve commit log]
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c97b1209
    • Jorge Lopez's avatar
      platform/x86: hp_wmi: Fix rfkill causing soft blocked wifi · b5835407
      Jorge Lopez authored
      commit 1598bfa8
      
       upstream.
      
      After upgrading BIOS to U82 01.02.01 Rev.A, the console is flooded
      strange char "^@" which printed out every second and makes login
      nearly impossible. Also the below messages were shown both in console
      and journal/dmesg every second:
      
      usb 1-3: Device not responding to setup address.
      usb 1-3: device not accepting address 4, error -71
      usb 1-3: device descriptor read/all, error -71
      usb usb1-port3: unable to enumerate USB device
      
      Wifi is soft blocked by checking rfkill. When unblocked manually,
      after few seconds it would be soft blocked again. So I was suspecting
      something triggered rfkill to soft block wifi.  At the end it was
      fixed by removing hp_wmi module.
      
      The root cause is the way hp-wmi driver handles command 1B on
      post-2009 BIOS.  In pre-2009 BIOS, command 1Bh return 0x4 to indicate
      that BIOS no longer controls the power for the wireless devices.
      
      Signed-off-by: default avatarJorge Lopez <jorge.lopez2@hp.com>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=216468
      Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Link: https://lore.kernel.org/r/20221028155527.7724-1-jorge.lopez2@hp.com
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5835407
    • Felix Kuehling's avatar
      drm/amdkfd: Fix error handling in kfd_criu_restore_events · 0a35e62c
      Felix Kuehling authored
      commit 66f79037 upstream.
      
      mutex_unlock before the exit label because all the error code paths that
      jump there didn't take that lock. This fixes unbalanced locking errors
      in case of restore errors.
      
      Fixes: 40e8a766
      
       ("drm/amdkfd: CRIU checkpoint and restore events")
      Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Reviewed-by: default avatarRajneesh Bhardwaj <rajneesh.bhardwaj@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>
      0a35e62c
    • Felix Kuehling's avatar
      drm/amdkfd: Fix error handling in criu_checkpoint · 182476d2
      Felix Kuehling authored
      commit b91c23e0 upstream.
      
      Checkpoint BOs last. That way we don't need to close dmabuf FDs if
      something else fails later. This avoids problematic access to user mode
      memory in the error handling code path.
      
      criu_checkpoint_bos has its own error handling and cleanup that does not
      depend on access to user memory.
      
      In the private data, keep BOs before the remaining objects. This is
      necessary to restore things in the correct order as restoring events
      depends on the events-page BO being restored first.
      
      Fixes: be072b06
      
       ("drm/amdkfd: CRIU export BOs as prime dmabuf objects")
      Reported-by: default avatarJann Horn <jannh@google.com>
      CC: Rajneesh Bhardwaj <Rajneesh.Bhardwaj@amd.com>
      Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Reviewed-and-tested-by: default avatarRajneesh Bhardwaj <rajneesh.bhardwaj@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>
      182476d2
    • Guchun Chen's avatar
      drm/amdgpu: disable BACO on special BEIGE_GOBY card · 3b351990
      Guchun Chen authored
      commit 0c85c067
      
       upstream.
      
      Still avoid intermittent failure.
      
      Signed-off-by: default avatarGuchun Chen <guchun.chen@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Acked-by: default avatarEvan Quan <evan.quan@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>
      3b351990
    • Christian König's avatar
      drm/amdgpu: workaround for TLB seq race · 712c02e5
      Christian König authored
      commit 77c092e0
      
       upstream.
      
      It can happen that we query the sequence value before the callback
      had a chance to run.
      
      Workaround that by grabbing the fence lock and releasing it again.
      Should be replaced by hw handling soon.
      
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      CC: stable@vger.kernel.org # 5.19+
      Fixes: 5255e146
      
       ("drm/amdgpu: rework TLB flushing")
      Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2113
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Acked-by: default avatarPhilip Yang <Philip.Yang@amd.com>
      Tested-by: default avatarStefan Springer <stefanspr94@gmail.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      712c02e5
    • Nicholas Kazlauskas's avatar
      drm/amd/display: Update SR watermarks for DCN314 · fac8ba99
      Nicholas Kazlauskas authored
      commit 632d0698
      
       upstream.
      
      [Why & How]
      New values requested by hardware after fine-tuning.
      Update for all memory types.
      
      Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
      Acked-by: default avatarAlan Liu <HaoPing.Liu@amd.com>
      Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.0.x
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fac8ba99
    • Tim Huang's avatar
      drm/amd/pm: update SMU IP v13.0.4 msg interface header · 121c6e55
      Tim Huang authored
      commit bc66c9ab
      
       upstream.
      
      Some of the unused messages that were used earlier in development have
      been freed up as spare messages, no intended functional changes.
      
      Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Signed-off-by: default avatarTim Huang <tim.huang@amd.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Reviewed-by: default avatarYifan Zhang <yifan1.zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.0.x
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      121c6e55
    • Nicholas Kazlauskas's avatar
      drm/amd/display: Fix reg timeout in enc314_enable_fifo · 51ff7cff
      Nicholas Kazlauskas authored
      commit ce62198d
      
       upstream.
      
      [Why]
      The link enablement sequence can end up resetting the encoder while
      the PHY symclk isn't yet on.
      
      This means that waiting for symclk on will timeout, along with the reset
      bit never asserting high.
      
      This causes unnecessary delay when enabling the link and produces a
      warning affecting multiple IGT tests.
      
      [How]
      Don't wait for the symclk to be on here because firmware already does.
      
      Don't wait for reset if we know the symclk isn't on.
      
      Split the reset into a helper function that checks the bit and decides
      whether or not a delay is sufficient.
      
      Reviewed-by: default avatarRoman Li <Roman.Li@amd.com>
      Acked-by: default avatarAlan Liu <HaoPing.Liu@amd.com>
      Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.0.x
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51ff7cff
    • Matthew Auld's avatar
      drm/i915/dmabuf: fix sg_table handling in map_dma_buf · ee6cff9a
      Matthew Auld authored
      commit f90daa97 upstream.
      
      We need to iterate over the original entries here for the sg_table,
      pulling out the struct page for each one, to be remapped. However
      currently this incorrectly iterates over the final dma mapped entries,
      which is likely just one gigantic sg entry if the iommu is enabled,
      leading to us only mapping the first struct page (and any physically
      contiguous pages following it), even if there is potentially lots more
      data to follow.
      
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7306
      Fixes: 1286ff73
      
       ("i915: add dmabuf/prime buffer sharing support.")
      Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Michael J. Ruhl <michael.j.ruhl@intel.com>
      Cc: <stable@vger.kernel.org> # v3.5+
      Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221028155029.494736-1-matthew.auld@intel.com
      (cherry picked from commit 28d52f99
      
      )
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee6cff9a
    • Ryusuke Konishi's avatar
      nilfs2: fix use-after-free bug of ns_writer on remount · b152300d
      Ryusuke Konishi authored
      commit 8cccf05f
      
       upstream.
      
      If a nilfs2 filesystem is downgraded to read-only due to metadata
      corruption on disk and is remounted read/write, or if emergency read-only
      remount is performed, detaching a log writer and synchronizing the
      filesystem can be done at the same time.
      
      In these cases, use-after-free of the log writer (hereinafter
      nilfs->ns_writer) can happen as shown in the scenario below:
      
       Task1                               Task2
       --------------------------------    ------------------------------
       nilfs_construct_segment
         nilfs_segctor_sync
           init_wait
           init_waitqueue_entry
           add_wait_queue
           schedule
                                           nilfs_remount (R/W remount case)
      				       nilfs_attach_log_writer
                                               nilfs_detach_log_writer
                                                 nilfs_segctor_destroy
                                                   kfree
           finish_wait
             _raw_spin_lock_irqsave
               __raw_spin_lock_irqsave
                 do_raw_spin_lock
                   debug_spin_lock_before  <-- use-after-free
      
      While Task1 is sleeping, nilfs->ns_writer is freed by Task2.  After Task1
      waked up, Task1 accesses nilfs->ns_writer which is already freed.  This
      scenario diagram is based on the Shigeru Yoshida's post [1].
      
      This patch fixes the issue by not detaching nilfs->ns_writer on remount so
      that this UAF race doesn't happen.  Along with this change, this patch
      also inserts a few necessary read-only checks with superblock instance
      where only the ns_writer pointer was used to check if the filesystem is
      read-only.
      
      Link: https://syzkaller.appspot.com/bug?id=79a4c002e960419ca173d55e863bd09e8112df8b
      Link: https://lkml.kernel.org/r/20221103141759.1836312-1-syoshida@redhat.com [1]
      Link: https://lkml.kernel.org/r/20221104142959.28296-1-konishi.ryusuke@gmail.com
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatar <syzbot+f816fa82f8783f7a02bb@syzkaller.appspotmail.com>
      Reported-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b152300d
    • Ryusuke Konishi's avatar
      nilfs2: fix deadlock in nilfs_count_free_blocks() · cb029b54
      Ryusuke Konishi authored
      commit 8ac932a4 upstream.
      
      A semaphore deadlock can occur if nilfs_get_block() detects metadata
      corruption while locating data blocks and a superblock writeback occurs at
      the same time:
      
      task 1                               task 2
      ------                               ------
      * A file operation *
      nilfs_truncate()
        nilfs_get_block()
          down_read(rwsem A) <--
          nilfs_bmap_lookup_contig()
            ...                            generic_shutdown_super()
                                             nilfs_put_super()
                                               * Prepare to write superblock *
                                               down_write(rwsem B) <--
                                               nilfs_cleanup_super()
            * Detect b-tree corruption *         nilfs_set_log_cursor()
            nilfs_bmap_convert_error()             nilfs_count_free_blocks()
              __nilfs_error()                        down_read(rwsem A) <--
                nilfs_set_error()
                  down_write(rwsem B) <--
      
                                 *** DEADLOCK ***
      
      Here, nilfs_get_block() readlocks rwsem A (= NILFS_MDT(dat_inode)->mi_sem)
      and then calls nilfs_bmap_lookup_contig(), but if it fails due to metadata
      corruption, __nilfs_error() is called from nilfs_bmap_convert_error()
      inside the lock section.
      
      Since __nilfs_error() calls nilfs_set_error() unless the filesystem is
      read-only and nilfs_set_error() attempts to writelock rwsem B (=
      nilfs->ns_sem) to write back superblock exclusively, hierarchical lock
      acquisition occurs in the order rwsem A -> rwsem B.
      
      Now, if another task starts updating the superblock, it may writelock
      rwsem B during the lock sequence above, and can deadlock trying to
      readlock rwsem A in nilfs_count_free_blocks().
      
      However, there is actually no need to take rwsem A in
      nilfs_count_free_blocks() because it, within the lock section, only reads
      a single integer data on a shared struct with
      nilfs_sufile_get_ncleansegs().  This has been the case after commit
      aa474a22 ("nilfs2: add local variable to cache the number of clean
      segments"), that is, even before this bug was introduced.
      
      So, this resolves the deadlock problem by just not taking the semaphore in
      nilfs_count_free_blocks().
      
      Link: https://lkml.kernel.org/r/20221029044912.9139-1-konishi.ryusuke@gmail.com
      Fixes: e828949e
      
       ("nilfs2: call nilfs_error inside bmap routines")
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatar <syzbot+45d6ce7b7ad7ef455d03@syzkaller.appspotmail.com>
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>	[2.6.38+
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb029b54
    • Shin'ichiro Kawasaki's avatar
      ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure · 42ebf596
      Shin'ichiro Kawasaki authored
      commit ea045fd3
      
       upstream.
      
      SAT SCSI/ATA Translation specification requires SCSI SYNCHRONIZE CACHE
      (10) and (16) commands both shall be translated to ATA flush command.
      Also, ZBC Zoned Block Commands specification mandates SYNCHRONIZE CACHE
      (16) command support. However, libata translates only SYNCHRONIZE CACHE
      (10). This results in SYNCHRONIZE CACHE (16) command failures on SATA
      drives and then libata translation does not conform to ZBC. To avoid the
      failure, add support for SYNCHRONIZE CACHE (16).
      
      Signed-off-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42ebf596
    • Nathan Chancellor's avatar
      vmlinux.lds.h: Fix placement of '.data..decrypted' section · 37ac9ac9
      Nathan Chancellor authored
      commit 000f8870 upstream.
      
      Commit d4c63999 ("vmlinux.lds.h: Avoid orphan section with !SMP")
      fixed an orphan section warning by adding the '.data..decrypted' section
      to the linker script under the PERCPU_DECRYPTED_SECTION define but that
      placement introduced a panic with !SMP, as the percpu sections are not
      instantiated with that configuration so attempting to access variables
      defined with DEFINE_PER_CPU_DECRYPTED() will result in a page fault.
      
      Move the '.data..decrypted' section to the DATA_MAIN define so that the
      variables in it are properly instantiated at boot time with
      CONFIG_SMP=n.
      
      Cc: stable@vger.kernel.org
      Fixes: d4c63999
      
       ("vmlinux.lds.h: Avoid orphan section with !SMP")
      Link: https://lore.kernel.org/cbbd3548-880c-d2ca-1b67-5bb93b291d5f@huawei.com/
      Debugged-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reported-by: default avatarZhao Wenhui <zhaowenhui8@huawei.com>
      Tested-by: default avatarxiafukun <xiafukun@huawei.com>
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221108174934.3384275-1-nathan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37ac9ac9
    • Jussi Laako's avatar
      ALSA: usb-audio: Add DSD support for Accuphase DAC-60 · 53127c3a
      Jussi Laako authored
      commit 8cbd4725
      
       upstream.
      
      Accuphase DAC-60 option card supports native DSD up to DSD256,
      but doesn't have support for auto-detection. Explicitly enable
      DSD support for the correct altsetting.
      
      Signed-off-by: default avatarJussi Laako <jussi@sonarnerd.net>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20221108221241.1220878-1-jussi@sonarnerd.net
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53127c3a
    • Takashi Iwai's avatar
      ALSA: usb-audio: Add quirk entry for M-Audio Micro · d1b00e7e
      Takashi Iwai authored
      commit 2f01a612
      
       upstream.
      
      M-Audio Micro (0762:201a) defines the descriptor as vendor-specific,
      while the content seems class-compliant.  Just overriding the probe
      makes the device working.
      
      Reported-by: default avatarAsh Logan <ash@heyquark.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/7ecd4417-d860-4773-c1c1-b07433342390@heyquark.com
      Link: https://lore.kernel.org/r/20221108140721.24248-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1b00e7e
    • Takashi Iwai's avatar
      ALSA: usb-audio: Yet more regression for for the delayed card registration · 4a9d883d
      Takashi Iwai authored
      commit 971cb608 upstream.
      
      Although we tried to fix the regression for the recent changes with
      the delayed card registration, it doesn't seem covering the all
      cases; e.g. on Roland EDIROL M-100FX, where the generic quirk for
      Roland devices is applied, it misses the card registration because the
      detection of the last interface (apparently for MIDI) fails.
      
      This patch is an attempt to recover from those failures by calling the
      card register also at the error path for the secondary interfaces.
      The card register condition is also extended to match with the old
      check in the previous patch, too (i.e. the simple check of the
      interface number) for catching the probe with errors.
      
      Fixes: 39efc9c8
      
       ("ALSA: usb-audio: Fix last interface check for registration")
      Cc: <stable@vger.kernel.org>
      Link: https://bugzilla.suse.com/show_bug.cgi?id=1205111
      Link: https://lore.kernel.org/r/20221108065824.14418-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a9d883d
    • Edson Juliano Drosdeck's avatar
      ALSA: hda/realtek: Add Positivo C6300 model quirk · 05040720
      Edson Juliano Drosdeck authored
      commit 79e28f2a
      
       upstream.
      
      Positivo Master C6300 (1849:a233) require quirk for anabling headset-mic
      
      Signed-off-by: default avatarEdson Juliano Drosdeck <edson.drosdeck@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20221109171732.5417-1-edson.drosdeck@gmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05040720
    • Stefan Binding's avatar
      ALSA: hda/realtek: Add quirk for ASUS Zenbook using CS35L41 · 163f2c98
      Stefan Binding authored
      commit 8d06679b
      
       upstream.
      
      This Asus Zenbook laptop use Realtek HDA codec combined with
      2xCS35L41 Amplifiers using I2C with Internal Boost.
      
      Signed-off-by: default avatarStefan Binding <sbinding@opensource.cirrus.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20221028102742.2588687-1-sbinding@opensource.cirrus.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      163f2c98
    • Ye Bin's avatar
      ALSA: hda: fix potential memleak in 'add_widget_node' · 455d99bd
      Ye Bin authored
      commit 9a5523f7
      
       upstream.
      
      As 'kobject_add' may allocated memory for 'kobject->name' when return error.
      And in this function, if call 'kobject_add' failed didn't free kobject.
      So call 'kobject_put' to recycling resources.
      
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20221110144539.2989354-1-yebin@huaweicloud.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      455d99bd
    • Xian Wang's avatar
      ALSA: hda/ca0132: add quirk for EVGA Z390 DARK · 724b4692
      Xian Wang authored
      commit 0c423e2f
      
       upstream.
      
      The Z390 DARK mainboard uses a CA0132 audio controller. The quirk is
      needed to enable surround sound and 3.5mm headphone jack handling in
      the front audio connector as well as in the rear of the board when in
      stereo mode.
      
      Page 97 of the linked manual contains instructions to setup the
      controller.
      
      Signed-off-by: default avatarXian Wang <dev@xianwang.io>
      Cc: stable@vger.kernel.org
      Link: https://www.evga.com/support/manuals/files/131-CS-E399.pdf
      Link: https://lore.kernel.org/r/20221104202913.13904-1-dev@xianwang.io
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      724b4692
    • Evan Quan's avatar
      ALSA: hda/hdmi - enable runtime pm for more AMD display audio · 99622458
      Evan Quan authored
      commit fdcc4c22
      
       upstream.
      
      We are able to power down the GPU and audio via the GPU driver
      so flag these asics as supporting runtime pm.
      
      Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20221108084746.583058-1-evan.quan@amd.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      99622458
    • Haibo Chen's avatar
      mmc: sdhci-esdhc-imx: use the correct host caps for MMC_CAP_8_BIT_DATA · 6050c0f7
      Haibo Chen authored
      commit f002f45a upstream.
      
      MMC_CAP_8_BIT_DATA belongs to struct mmc_host, not struct sdhci_host.
      So correct it here.
      
      Fixes: 1ed5c3b2
      
       ("mmc: sdhci-esdhc-imx: Propagate ESDHC_FLAG_HS400* only on 8bit bus")
      Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Cc: stable@vger.kernel.org
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/1667893503-20583-1-git-send-email-haibo.chen@nxp.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6050c0f7
    • Brian Norris's avatar
      mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI · f85d9b9c
      Brian Norris authored
      commit 83607844 upstream.
      
      [[ NOTE: this is completely untested by the author, but included solely
          because, as noted in commit df57d732 ("mmc: sdhci-pci: Fix
          SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
          drivers using CQHCI might benefit from a similar change, if they
          also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
          bug on at least MSM, Arasan, and Intel hardware. ]]
      
      SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
      tracking that properly in software. When out of sync, we may trigger
      various timeouts.
      
      It's not typical to perform resets while CQE is enabled, but this may
      occur in some suspend or error recovery scenarios.
      
      Include this fix by way of the new sdhci_and_cqhci_reset() helper.
      
      This patch depends on (and should not compile without) the patch
      entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
      CQHCI".
      
      Fixes: 3c4019f9
      
       ("mmc: tegra: HW Command Queue Support for Tegra SDMMC")
      Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221026124150.v4.5.I418c9eaaf754880fcd2698113e8c3ef821a944d7@changeid
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f85d9b9c