Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jan 14, 2025
    • Linus Torvalds's avatar
      Merge tag 'pci-v6.13-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci · 7f5b6a8e
      Linus Torvalds authored
      Pull pci fix from Bjorn Helgaas:
      
       - Prevent bwctrl NULL pointer dereference that caused hangs on shutdown
         on ASUS ROG Strix SCAR 17 G733PYV (Lukas Wunner)
      
      * tag 'pci-v6.13-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci:
        PCI/bwctrl: Fix NULL pointer deref on unbind and bind
      7f5b6a8e
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · c3812b15
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "One iscsi driver fix and one core fix.
      
        The core fix is an important one because a retry efficiency update is
        now causing some USB devices to get the wrong size on discovery (it
        upset their retry logic for READ_CAPACITY_16)"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: iscsi: Fix redundant response for ISCSI_UEVENT_GET_HOST_STATS request
        scsi: core: Fix command pass through retry regression
      c3812b15
    • Linus Torvalds's avatar
      Merge tag 'sound-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 79a1d390
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "Hopefully the last PR for 6.13. This became bigger than wished due to
        the timing after holiday breaks.
      
        The only large LOC is the additional document for Cirrus codec which
        is nice for users (and absolutely safe). All the rest are small fixes
        in ASoC Rcar and codecs as well as HD-audio quirks (And no fix for USB
        guitar pedals seen yet :)"
      
      * tag 'sound-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: hda/realtek: Fix volume adjustment issue on Lenovo ThinkBook 16P Gen5
        ALSA: hda/realtek: fixup ASUS H7606W
        ALSA: hda/realtek: fixup ASUS GA605W
        ALSA: hda/realtek: Add support for Ayaneo System using CS35L41 HDA
        ASoC: rsnd: check rsnd_adg_clk_enable() return value
        ASoC: cs42l43: Add codec force suspend/resume ops
        ALSA: doc: Add codecs/index.rst to top-level index
        ALSA: doc: cs35l56: Add information about Cirrus Logic CS35L54/56/57
        ASoC: samsung: Add missing depends on I2C
        MAINTAINERS: add missing maintainers for Simple Audio Card
        ASoC: samsung: Add missing selects for MFD_WM8994
        ASoC: codecs: es8316: Fix HW rate calculation for 48Mhz MCLK
        ASoC: wm8994: Add depends on MFD core
        ASoC: tas2781: Fix occasional calibration failture
        ASoC: codecs: ES8326: Adjust ANA_MICBIAS to reduce pop noise
      79a1d390
  2. Jan 13, 2025
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2025-01-13-00-03' of... · c45323b7
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2025-01-13-00-03' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull misc fixes from Andrew Morton:
       "18 hotfixes. 11 are cc:stable. 13 are MM and 5 are non-MM.
      
        All patches are singletons - please see the relevant changelogs for
        details"
      
      * tag 'mm-hotfixes-stable-2025-01-13-00-03' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        fs/proc: fix softlockup in __read_vmcore (part 2)
        mm: fix assertion in folio_end_read()
        mm: vmscan : pgdemote vmstat is not getting updated when MGLRU is enabled.
        vmstat: disable vmstat_work on vmstat_cpu_down_prep()
        zram: fix potential UAF of zram table
        selftests/mm: set allocated memory to non-zero content in cow test
        mm: clear uffd-wp PTE/PMD state on mremap()
        module: fix writing of livepatch relocations in ROX text
        mm: zswap: properly synchronize freeing resources during CPU hotunplug
        Revert "mm: zswap: fix race between [de]compression and CPU hotunplug"
        hugetlb: fix NULL pointer dereference in trace_hugetlbfs_alloc_inode
        mm: fix div by zero in bdi_ratio_from_pages
        x86/execmem: fix ROX cache usage in Xen PV guests
        filemap: avoid truncating 64-bit offset to 32 bits
        tools: fix atomic_set() definition to set the value correctly
        mm/mempolicy: count MPOL_WEIGHTED_INTERLEAVE to "interleave_hit"
        scripts/decode_stacktrace.sh: fix decoding of lines with an additional info
        mm/kmemleak: fix percpu memory leak detection failure
      c45323b7
    • Yage Geng's avatar
      ALSA: hda/realtek: Fix volume adjustment issue on Lenovo ThinkBook 16P Gen5 · 34c8e74c
      Yage Geng authored
      
      This patch fixes the volume adjustment issue on the Lenovo ThinkBook 16P Gen5
      by applying the necessary quirk configuration for the Realtek ALC287 codec.
      
      The issue was caused by incorrect configuration in the driver,
      which prevented proper volume control on certain systems.
      
      Signed-off-by: default avatarYage Geng <icoderdev@gmail.com>
      Link: https://patch.msgid.link/20250113085208.15351-1-icoderdev@gmail.com
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      34c8e74c
  3. Jan 12, 2025
    • Rik van Riel's avatar
      fs/proc: fix softlockup in __read_vmcore (part 2) · cbc5dde0
      Rik van Riel authored
      Since commit 5cbcb62d ("fs/proc: fix softlockup in __read_vmcore") the
      number of softlockups in __read_vmcore at kdump time have gone down, but
      they still happen sometimes.
      
      In a memory constrained environment like the kdump image, a softlockup is
      not just a harmless message, but it can interfere with things like RCU
      freeing memory, causing the crashdump to get stuck.
      
      The second loop in __read_vmcore has a lot more opportunities for natural
      sleep points, like scheduling out while waiting for a data write to
      happen, but apparently that is not always enough.
      
      Add a cond_resched() to the second loop in __read_vmcore to (hopefully)
      get rid of the softlockups.
      
      Link: https://lkml.kernel.org/r/20250110102821.2a37581b@fangorn
      Fixes: 5cbcb62d
      
       ("fs/proc: fix softlockup in __read_vmcore")
      Signed-off-by: default avatarRik van Riel <riel@surriel.com>
      Reported-by: default avatarBreno Leitao <leitao@debian.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      cbc5dde0
    • Matthew Wilcox (Oracle)'s avatar
      mm: fix assertion in folio_end_read() · 1c47c578
      Matthew Wilcox (Oracle) authored
      We only need to assert that the uptodate flag is clear if we're going to
      set it.  This hasn't been a problem before now because we have only used
      folio_end_read() when completing with an error, but it's convenient to use
      it in squashfs if we discover the folio is already uptodate.
      
      Link: https://lkml.kernel.org/r/20250110163300.3346321-1-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Phillip Lougher <phillip@squashfs.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1c47c578
    • Donet Tom's avatar
      mm: vmscan : pgdemote vmstat is not getting updated when MGLRU is enabled. · bd3d56ff
      Donet Tom authored
      When MGLRU is enabled, the pgdemote_kswapd, pgdemote_direct, and
      pgdemote_khugepaged stats in vmstat are not being updated.
      
      Commit f77f0c75 ("mm,memcg: provide per-cgroup counters for NUMA
      balancing operations") moved the pgdemote vmstat update from
      demote_folio_list() to shrink_inactive_list(), which is in the normal LRU
      path.  As a result, the pgdemote stats are updated correctly for the
      normal LRU but not for MGLRU.
      
      To address this, we have added the pgdemote stat update in the
      evict_folios() function, which is in the MGLRU path.  With this patch, the
      pgdemote stats will now be updated correctly when MGLRU is enabled.
      
      Without this patch vmstat output when MGLRU is enabled
      ======================================================
      pgdemote_kswapd 0
      pgdemote_direct 0
      pgdemote_khugepaged 0
      
      With this patch vmstat output when MGLRU is enabled
      ===================================================
      pgdemote_kswapd 43234
      pgdemote_direct 4691
      pgdemote_khugepaged 0
      
      Link: https://lkml.kernel.org/r/20250109060540.451261-1-donettom@linux.ibm.com
      Fixes: f77f0c75
      
       ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")
      Signed-off-by: default avatarDonet Tom <donettom@linux.ibm.com>
      Acked-by: default avatarYu Zhao <yuzhao@google.com>
      Tested-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
      Reviewed-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
      Cc: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Kaiyang Zhao <kaiyang2@cs.cmu.edu>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Muchun Song <muchun.song@linux.dev>
      Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Shakeel Butt <shakeel.butt@linux.dev>
      Cc: Wei Xu <weixugc@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      bd3d56ff
    • Koichiro Den's avatar
      vmstat: disable vmstat_work on vmstat_cpu_down_prep() · 9fd8fcf1
      Koichiro Den authored
      The upstream commit adcfb264 ("vmstat: disable vmstat_work on
      vmstat_cpu_down_prep()") introduced another warning during the boot phase
      so was soon reverted on upstream by commit cd6313be ("Revert "vmstat:
      disable vmstat_work on vmstat_cpu_down_prep()"").  This commit resolves it
      and reattempts the original fix.
      
      Even after mm/vmstat:online teardown, shepherd may still queue work for
      the dying cpu until the cpu is removed from online mask.  While it's quite
      rare, this means that after unbind_workers() unbinds a per-cpu kworker, it
      potentially runs vmstat_update for the dying CPU on an irrelevant cpu
      before entering atomic AP states.  When CONFIG_DEBUG_PREEMPT=y, it results
      in the following error with the backtrace.
      
        BUG: using smp_processor_id() in preemptible [00000000] code: \
                                                     kworker/7:3/1702
        caller is refresh_cpu_vm_stats+0x235/0x5f0
        CPU: 0 UID: 0 PID: 1702 Comm: kworker/7:3 Tainted: G
        Tainted: [N]=TEST
        Workqueue: mm_percpu_wq vmstat_update
        Call Trace:
         <TASK>
         dump_stack_lvl+0x8d/0xb0
         check_preemption_disabled+0xce/0xe0
         refresh_cpu_vm_stats+0x235/0x5f0
         vmstat_update+0x17/0xa0
         process_one_work+0x869/0x1aa0
         worker_thread+0x5e5/0x1100
         kthread+0x29e/0x380
         ret_from_fork+0x2d/0x70
         ret_from_fork_asm+0x1a/0x30
         </TASK>
      
      So, for mm/vmstat:online, disable vmstat_work reliably on teardown and
      symmetrically enable it on startup.
      
      For secondary CPUs during CPU hotplug scenarios, ensure the delayed work
      is disabled immediately after the initialization.  These CPUs are not yet
      online when start_shepherd_timer() runs on boot CPU.  vmstat_cpu_online()
      will enable the work for them.
      
      Link: https://lkml.kernel.org/r/20250108042807.3429745-1-koichiro.den@canonical.com
      
      
      Signed-off-by: default avatarHuacai Chen <chenhuacai@kernel.org>
      Signed-off-by: default avatarKoichiro Den <koichiro.den@canonical.com>
      Suggested-by: default avatarHuacai Chen <chenhuacai@kernel.org>
      Tested-by: default avatarCharalampos Mitrodimas <charmitro@posteo.net>
      Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9fd8fcf1
    • Kairui Song's avatar
      zram: fix potential UAF of zram table · 212fe1c0
      Kairui Song authored
      If zram_meta_alloc failed early, it frees allocated zram->table without
      setting it NULL.  Which will potentially cause zram_meta_free to access
      the table if user reset an failed and uninitialized device.
      
      Link: https://lkml.kernel.org/r/20250107065446.86928-1-ryncsn@gmail.com
      Fixes: 74363ec6
      
       ("zram: fix uninitialized ZRAM not releasing backing device")
      Signed-off-by: default avatarKairui Song <kasong@tencent.com>
      Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      212fe1c0
    • Ryan Roberts's avatar
      selftests/mm: set allocated memory to non-zero content in cow test · a32bf5bb
      Ryan Roberts authored
      After commit b1f20206 ("mm: remap unused subpages to shared zeropage
      when splitting isolated thp"), cow test cases involving swapping out THPs
      via madvise(MADV_PAGEOUT) started to be skipped due to the subsequent
      check via pagemap determining that the memory was not actually swapped
      out.  Logs similar to this were emitted:
      
         ...
      
         # [RUN] Basic COW after fork() ... with swapped-out, PTE-mapped THP (16 kB)
         ok 2 # SKIP MADV_PAGEOUT did not work, is swap enabled?
         # [RUN] Basic COW after fork() ... with single PTE of swapped-out THP (16 kB)
         ok 3 # SKIP MADV_PAGEOUT did not work, is swap enabled?
         # [RUN] Basic COW after fork() ... with swapped-out, PTE-mapped THP (32 kB)
         ok 4 # SKIP MADV_PAGEOUT did not work, is swap enabled?
      
         ...
      
      The commit in question introduces the behaviour of scanning THPs and if
      their content is predominantly zero, it splits them and replaces the pages
      which are wholly zero with the zero page.  These cow test cases were
      getting caught up in this.
      
      So let's avoid that by filling the contents of all allocated memory with
      a non-zero value. With this in place, the tests are passing again.
      
      Link: https://lkml.kernel.org/r/20250107142555.1870101-1-ryan.roberts@arm.com
      Fixes: b1f20206
      
       ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
      Signed-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Usama Arif <usamaarif642@gmail.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a32bf5bb
    • Ryan Roberts's avatar
      mm: clear uffd-wp PTE/PMD state on mremap() · 0cef0bb8
      Ryan Roberts authored
      When mremap()ing a memory region previously registered with userfaultfd as
      write-protected but without UFFD_FEATURE_EVENT_REMAP, an inconsistency in
      flag clearing leads to a mismatch between the vma flags (which have
      uffd-wp cleared) and the pte/pmd flags (which do not have uffd-wp
      cleared).  This mismatch causes a subsequent mprotect(PROT_WRITE) to
      trigger a warning in page_table_check_pte_flags() due to setting the pte
      to writable while uffd-wp is still set.
      
      Fix this by always explicitly clearing the uffd-wp pte/pmd flags on any
      such mremap() so that the values are consistent with the existing clearing
      of VM_UFFD_WP.  Be careful to clear the logical flag regardless of its
      physical form; a PTE bit, a swap PTE bit, or a PTE marker.  Cover PTE,
      huge PMD and hugetlb paths.
      
      Link: https://lkml.kernel.org/r/20250107144755.1871363-2-ryan.roberts@arm.com
      
      
      Co-developed-by: default avatarMikołaj Lenczewski <miko.lenczewski@arm.com>
      Signed-off-by: default avatarMikołaj Lenczewski <miko.lenczewski@arm.com>
      Signed-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Closes: https://lore.kernel.org/linux-mm/810b44a8-d2ae-4107-b665-5a42eae2d948@arm.com/
      Fixes: 63b2d417
      
       ("userfaultfd: wp: add the writeprotect API to userfaultfd ioctl")
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
      Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Muchun Song <muchun.song@linux.dev>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0cef0bb8
    • Petr Pavlu's avatar
      module: fix writing of livepatch relocations in ROX text · 4bcf2974
      Petr Pavlu authored
      A livepatch module can contain a special relocation section
      .klp.rela.<objname>.<secname> to apply its relocations at the appropriate
      time and to additionally access local and unexported symbols.  When
      <objname> points to another module, such relocations are processed
      separately from the regular module relocation process.  For instance, only
      when the target <objname> actually becomes loaded.
      
      With CONFIG_STRICT_MODULE_RWX, when the livepatch core decides to apply
      these relocations, their processing results in the following bug:
      
      [   25.827238] BUG: unable to handle page fault for address: 00000000000012ba
      [   25.827819] #PF: supervisor read access in kernel mode
      [   25.828153] #PF: error_code(0x0000) - not-present page
      [   25.828588] PGD 0 P4D 0
      [   25.829063] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI
      [   25.829742] CPU: 2 UID: 0 PID: 452 Comm: insmod Tainted: G O  K    6.13.0-rc4-00078-g059dd502b263 #7820
      [   25.830417] Tainted: [O]=OOT_MODULE, [K]=LIVEPATCH
      [   25.830768] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-20220807_005459-localhost 04/01/2014
      [   25.831651] RIP: 0010:memcmp+0x24/0x60
      [   25.832190] Code: [...]
      [   25.833378] RSP: 0018:ffffa40b403a3ae8 EFLAGS: 00000246
      [   25.833637] RAX: 0000000000000000 RBX: ffff93bc81d8e700 RCX: ffffffffc0202000
      [   25.834072] RDX: 0000000000000000 RSI: 0000000000000004 RDI: 00000000000012ba
      [   25.834548] RBP: ffffa40b403a3b68 R08: ffffa40b403a3b30 R09: 0000004a00000002
      [   25.835088] R10: ffffffffffffd222 R11: f000000000000000 R12: 0000000000000000
      [   25.835666] R13: ffffffffc02032ba R14: ffffffffc007d1e0 R15: 0000000000000004
      [   25.836139] FS:  00007fecef8c3080(0000) GS:ffff93bc8f900000(0000) knlGS:0000000000000000
      [   25.836519] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   25.836977] CR2: 00000000000012ba CR3: 0000000002f24000 CR4: 00000000000006f0
      [   25.837442] Call Trace:
      [   25.838297]  <TASK>
      [   25.841083]  __write_relocate_add.constprop.0+0xc7/0x2b0
      [   25.841701]  apply_relocate_add+0x75/0xa0
      [   25.841973]  klp_write_section_relocs+0x10e/0x140
      [   25.842304]  klp_write_object_relocs+0x70/0xa0
      [   25.842682]  klp_init_object_loaded+0x21/0xf0
      [   25.842972]  klp_enable_patch+0x43d/0x900
      [   25.843572]  do_one_initcall+0x4c/0x220
      [   25.844186]  do_init_module+0x6a/0x260
      [   25.844423]  init_module_from_file+0x9c/0xe0
      [   25.844702]  idempotent_init_module+0x172/0x270
      [   25.845008]  __x64_sys_finit_module+0x69/0xc0
      [   25.845253]  do_syscall_64+0x9e/0x1a0
      [   25.845498]  entry_SYSCALL_64_after_hwframe+0x77/0x7f
      [   25.846056] RIP: 0033:0x7fecef9eb25d
      [   25.846444] Code: [...]
      [   25.847563] RSP: 002b:00007ffd0c5d6de8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [   25.848082] RAX: ffffffffffffffda RBX: 000055b03f05e470 RCX: 00007fecef9eb25d
      [   25.848456] RDX: 0000000000000000 RSI: 000055b001e74e52 RDI: 0000000000000003
      [   25.848969] RBP: 00007ffd0c5d6ea0 R08: 0000000000000040 R09: 0000000000004100
      [   25.849411] R10: 00007fecefac7b20 R11: 0000000000000246 R12: 000055b001e74e52
      [   25.849905] R13: 0000000000000000 R14: 000055b03f05e440 R15: 0000000000000000
      [   25.850336]  </TASK>
      [   25.850553] Modules linked in: deku(OK+) uinput
      [   25.851408] CR2: 00000000000012ba
      [   25.852085] ---[ end trace 0000000000000000 ]---
      
      The problem is that the .klp.rela.<objname>.<secname> relocations are
      processed after the module was already formed and mod->rw_copy was reset. 
      However, the code in __write_relocate_add() calls
      module_writable_address() which translates the target address 'loc' still
      to 'loc + (mem->rw_copy - mem->base)', with mem->rw_copy now being 0.
      
      Fix the problem by returning directly 'loc' in module_writable_address()
      when the module is already formed.  Function __write_relocate_add() knows
      to use text_poke() in such a case.
      
      Link: https://lkml.kernel.org/r/20250107153507.14733-1-petr.pavlu@suse.com
      Fixes: 0c133b1e
      
       ("module: prepare to handle ROX allocations for text")
      Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
      Reported-by: default avatarMarek Maslanka <mmaslanka@google.com>
      Closes: https://lore.kernel.org/linux-modules/CAGcaFA2hdThQV6mjD_1_U+GNHThv84+MQvMWLgEuX+LVbAyDxg@mail.gmail.com/
      
      
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Tested-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: Joe Lawrence <joe.lawrence@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4bcf2974
    • Yosry Ahmed's avatar
      mm: zswap: properly synchronize freeing resources during CPU hotunplug · 12dcb0ef
      Yosry Ahmed authored
      In zswap_compress() and zswap_decompress(), the per-CPU acomp_ctx of the
      current CPU at the beginning of the operation is retrieved and used
      throughout.  However, since neither preemption nor migration are disabled,
      it is possible that the operation continues on a different CPU.
      
      If the original CPU is hotunplugged while the acomp_ctx is still in use,
      we run into a UAF bug as some of the resources attached to the acomp_ctx
      are freed during hotunplug in zswap_cpu_comp_dead() (i.e. 
      acomp_ctx.buffer, acomp_ctx.req, or acomp_ctx.acomp).
      
      The problem was introduced in commit 1ec3b5fe ("mm/zswap: move to use
      crypto_acomp API for hardware acceleration") when the switch to the
      crypto_acomp API was made.  Prior to that, the per-CPU crypto_comp was
      retrieved using get_cpu_ptr() which disables preemption and makes sure the
      CPU cannot go away from under us.  Preemption cannot be disabled with the
      crypto_acomp API as a sleepable context is needed.
      
      Use the acomp_ctx.mutex to synchronize CPU hotplug callbacks allocating
      and freeing resources with compression/decompression paths.  Make sure
      that acomp_ctx.req is NULL when the resources are freed.  In the
      compression/decompression paths, check if acomp_ctx.req is NULL after
      acquiring the mutex (meaning the CPU was offlined) and retry on the new
      CPU.
      
      The initialization of acomp_ctx.mutex is moved from the CPU hotplug
      callback to the pool initialization where it belongs (where the mutex is
      allocated).  In addition to adding clarity, this makes sure that CPU
      hotplug cannot reinitialize a mutex that is already locked by
      compression/decompression.
      
      Previously a fix was attempted by holding cpus_read_lock() [1].  This
      would have caused a potential deadlock as it is possible for code already
      holding the lock to fall into reclaim and enter zswap (causing a
      deadlock).  A fix was also attempted using SRCU for synchronization, but
      Johannes pointed out that synchronize_srcu() cannot be used in CPU hotplug
      notifiers [2].
      
      Alternative fixes that were considered/attempted and could have worked:
      - Refcounting the per-CPU acomp_ctx. This involves complexity in
        handling the race between the refcount dropping to zero in
        zswap_[de]compress() and the refcount being re-initialized when the
        CPU is onlined.
      - Disabling migration before getting the per-CPU acomp_ctx [3], but
        that's discouraged and is a much bigger hammer than needed, and could
        result in subtle performance issues.
      
      [1]https://lkml.kernel.org/20241219212437.2714151-1-yosryahmed@google.com/
      [2]https://lkml.kernel.org/20250107074724.1756696-2-yosryahmed@google.com/
      [3]https://lkml.kernel.org/20250107222236.2715883-2-yosryahmed@google.com/
      
      [yosryahmed@google.com: remove comment]
        Link: https://lkml.kernel.org/r/CAJD7tkaxS1wjn+swugt8QCvQ-rVF5RZnjxwPGX17k8x9zSManA@mail.gmail.com
      Link: https://lkml.kernel.org/r/20250108222441.3622031-1-yosryahmed@google.com
      Fixes: 1ec3b5fe
      
       ("mm/zswap: move to use crypto_acomp API for hardware acceleration")
      Signed-off-by: default avatarYosry Ahmed <yosryahmed@google.com>
      Reported-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Closes: https://lore.kernel.org/lkml/20241113213007.GB1564047@cmpxchg.org/
      
      
      Reported-by: default avatarSam Sun <samsun1006219@gmail.com>
      Closes: https://lore.kernel.org/lkml/CAEkJfYMtSdM5HceNsXUDf5haghD5+o2e7Qv4OcuruL4tPg6OaQ@mail.gmail.com/
      
      
      Cc: Barry Song <baohua@kernel.org>
      Cc: Chengming Zhou <chengming.zhou@linux.dev>
      Cc: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
      Cc: Nhat Pham <nphamcs@gmail.com>
      Cc: Vitaly Wool <vitalywool@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      12dcb0ef
    • Yosry Ahmed's avatar
      Revert "mm: zswap: fix race between [de]compression and CPU hotunplug" · 4dff389c
      Yosry Ahmed authored
      This reverts commit eaebeb93.
      
      Commit eaebeb93 ("mm: zswap: fix race between [de]compression and CPU
      hotunplug") used the CPU hotplug lock in zswap compress/decompress
      operations to protect against a race with CPU hotunplug making some
      per-CPU resources go away.
      
      However, zswap compress/decompress can be reached through reclaim while
      the lock is held, resulting in a potential deadlock as reported by syzbot:
      ======================================================
      WARNING: possible circular locking dependency detected
      6.13.0-rc6-syzkaller-00006-g5428dc1906dd #0 Not tainted
      ------------------------------------------------------
      kswapd0/89 is trying to acquire lock:
       ffffffff8e7d2ed0 (cpu_hotplug_lock){++++}-{0:0}, at: acomp_ctx_get_cpu mm/zswap.c:886 [inline]
       ffffffff8e7d2ed0 (cpu_hotplug_lock){++++}-{0:0}, at: zswap_compress mm/zswap.c:908 [inline]
       ffffffff8e7d2ed0 (cpu_hotplug_lock){++++}-{0:0}, at: zswap_store_page mm/zswap.c:1439 [inline]
       ffffffff8e7d2ed0 (cpu_hotplug_lock){++++}-{0:0}, at: zswap_store+0xa74/0x1ba0 mm/zswap.c:1546
      
      but task is already holding lock:
       ffffffff8ea355a0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat mm/vmscan.c:6871 [inline]
       ffffffff8ea355a0 (fs_reclaim){+.+.}-{0:0}, at: kswapd+0xb58/0x2f30 mm/vmscan.c:7253
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #1 (fs_reclaim){+.+.}-{0:0}:
              lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
              __fs_reclaim_acquire mm/page_alloc.c:3853 [inline]
              fs_reclaim_acquire+0x88/0x130 mm/page_alloc.c:3867
              might_alloc include/linux/sched/mm.h:318 [inline]
              slab_pre_alloc_hook mm/slub.c:4070 [inline]
              slab_alloc_node mm/slub.c:4148 [inline]
              __kmalloc_cache_node_noprof+0x40/0x3a0 mm/slub.c:4337
              kmalloc_node_noprof include/linux/slab.h:924 [inline]
              alloc_worker kernel/workqueue.c:2638 [inline]
              create_worker+0x11b/0x720 kernel/workqueue.c:2781
              workqueue_prepare_cpu+0xe3/0x170 kernel/workqueue.c:6628
              cpuhp_invoke_callback+0x48d/0x830 kernel/cpu.c:194
              __cpuhp_invoke_callback_range kernel/cpu.c:965 [inline]
              cpuhp_invoke_callback_range kernel/cpu.c:989 [inline]
              cpuhp_up_callbacks kernel/cpu.c:1020 [inline]
              _cpu_up+0x2b3/0x580 kernel/cpu.c:1690
              cpu_up+0x184/0x230 kernel/cpu.c:1722
              cpuhp_bringup_mask+0xdf/0x260 kernel/cpu.c:1788
              cpuhp_bringup_cpus_parallel+0xf9/0x160 kernel/cpu.c:1878
              bringup_nonboot_cpus+0x2b/0x50 kernel/cpu.c:1892
              smp_init+0x34/0x150 kernel/smp.c:1009
              kernel_init_freeable+0x417/0x5d0 init/main.c:1569
              kernel_init+0x1d/0x2b0 init/main.c:1466
              ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
              ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
      
      -> #0 (cpu_hotplug_lock){++++}-{0:0}:
              check_prev_add kernel/locking/lockdep.c:3161 [inline]
              check_prevs_add kernel/locking/lockdep.c:3280 [inline]
              validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
              __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
              lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
              percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
              cpus_read_lock+0x42/0x150 kernel/cpu.c:490
              acomp_ctx_get_cpu mm/zswap.c:886 [inline]
              zswap_compress mm/zswap.c:908 [inline]
              zswap_store_page mm/zswap.c:1439 [inline]
              zswap_store+0xa74/0x1ba0 mm/zswap.c:1546
              swap_writepage+0x647/0xce0 mm/page_io.c:279
              shmem_writepage+0x1248/0x1610 mm/shmem.c:1579
              pageout mm/vmscan.c:696 [inline]
              shrink_folio_list+0x35ee/0x57e0 mm/vmscan.c:1374
              shrink_inactive_list mm/vmscan.c:1967 [inline]
              shrink_list mm/vmscan.c:2205 [inline]
              shrink_lruvec+0x16db/0x2f30 mm/vmscan.c:5734
              mem_cgroup_shrink_node+0x385/0x8e0 mm/vmscan.c:6575
              mem_cgroup_soft_reclaim mm/memcontrol-v1.c:312 [inline]
              memcg1_soft_limit_reclaim+0x346/0x810 mm/memcontrol-v1.c:362
              balance_pgdat mm/vmscan.c:6975 [inline]
              kswapd+0x17b3/0x2f30 mm/vmscan.c:7253
              kthread+0x2f0/0x390 kernel/kthread.c:389
              ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
              ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
      
      other info that might help us debug this:
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(fs_reclaim);
                                     lock(cpu_hotplug_lock);
                                     lock(fs_reclaim);
        rlock(cpu_hotplug_lock);
      
       *** DEADLOCK ***
      
      1 lock held by kswapd0/89:
        #0: ffffffff8ea355a0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat mm/vmscan.c:6871 [inline]
        #0: ffffffff8ea355a0 (fs_reclaim){+.+.}-{0:0}, at: kswapd+0xb58/0x2f30 mm/vmscan.c:7253
      
      stack backtrace:
      CPU: 0 UID: 0 PID: 89 Comm: kswapd0 Not tainted 6.13.0-rc6-syzkaller-00006-g5428dc1906dd #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
      Call Trace:
       <TASK>
        __dump_stack lib/dump_stack.c:94 [inline]
        dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
        print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074
        check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206
        check_prev_add kernel/locking/lockdep.c:3161 [inline]
        check_prevs_add kernel/locking/lockdep.c:3280 [inline]
        validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
        __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
        lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
        percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
        cpus_read_lock+0x42/0x150 kernel/cpu.c:490
        acomp_ctx_get_cpu mm/zswap.c:886 [inline]
        zswap_compress mm/zswap.c:908 [inline]
        zswap_store_page mm/zswap.c:1439 [inline]
        zswap_store+0xa74/0x1ba0 mm/zswap.c:1546
        swap_writepage+0x647/0xce0 mm/page_io.c:279
        shmem_writepage+0x1248/0x1610 mm/shmem.c:1579
        pageout mm/vmscan.c:696 [inline]
        shrink_folio_list+0x35ee/0x57e0 mm/vmscan.c:1374
        shrink_inactive_list mm/vmscan.c:1967 [inline]
        shrink_list mm/vmscan.c:2205 [inline]
        shrink_lruvec+0x16db/0x2f30 mm/vmscan.c:5734
        mem_cgroup_shrink_node+0x385/0x8e0 mm/vmscan.c:6575
        mem_cgroup_soft_reclaim mm/memcontrol-v1.c:312 [inline]
        memcg1_soft_limit_reclaim+0x346/0x810 mm/memcontrol-v1.c:362
        balance_pgdat mm/vmscan.c:6975 [inline]
        kswapd+0x17b3/0x2f30 mm/vmscan.c:7253
        kthread+0x2f0/0x390 kernel/kthread.c:389
        ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
        ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
       </TASK>
      
      Revert the change. A different fix for the race with CPU hotunplug will
      follow.
      
      Link: https://lkml.kernel.org/r/20250107222236.2715883-1-yosryahmed@google.com
      
      
      Signed-off-by: default avatarYosry Ahmed <yosryahmed@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Barry Song <baohua@kernel.org>
      Cc: Chengming Zhou <chengming.zhou@linux.dev>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
      Cc: Nhat Pham <nphamcs@gmail.com>
      Cc: Sam Sun <samsun1006219@gmail.com>
      Cc: Vitaly Wool <vitalywool@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4dff389c
    • Muchun Song's avatar
      hugetlb: fix NULL pointer dereference in trace_hugetlbfs_alloc_inode · 9ab96b52
      Muchun Song authored
      hugetlb_file_setup() will pass a NULL @dir to hugetlbfs_get_inode(), so we
      will access a NULL pointer for @dir.  Fix it and set __entry->dr to 0 if
      @dir is NULL.  Because ->i_ino cannot be 0 (see get_next_ino()), there is
      no confusing if user sees a 0 inode number.
      
      Link: https://lkml.kernel.org/r/20250106033118.4640-1-songmuchun@bytedance.com
      Fixes: 318580ad
      
       ("hugetlbfs: support tracepoint")
      Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Reported-by: default avatarCheung Wall <zzqq0103.hey@gmail.com>
      Closes: https://lore.kernel.org/linux-mm/02858D60-43C1-4863-A84F-3C76A8AF1F15@linux.dev/T/#
      
      
      Reviewed-by: default avatarHongbo Li <lihongbo22@huawei.com>
      Cc: cheung wall <zzqq0103.hey@gmail.com>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9ab96b52
    • Stefan Roesch's avatar
      mm: fix div by zero in bdi_ratio_from_pages · 4ce718f3
      Stefan Roesch authored
      During testing it has been detected, that it is possible to get div by
      zero error in bdi_set_min_bytes.  The error is caused by the function
      bdi_ratio_from_pages().  bdi_ratio_from_pages() calls global_dirty_limits.
      If the dirty threshold is 0, the div by zero is raised.  This can happen
      if the root user is setting:
      
      echo 0 > /proc/sys/vm/dirty_ratio
      
      The following is a test case:
      
      echo 0 > /proc/sys/vm/dirty_ratio
      cd /sys/class/bdi/<device>
      echo 1 > strict_limit
      echo 8192 > min_bytes
      
      ==> error is raised.
      
      The problem is addressed by returning -EINVAL if dirty_ratio or
      dirty_bytes is set to 0.
      
      [shr@devkernel.io: check for -EINVAL in bdi_set_min_bytes() and bdi_set_max_bytes()]
        Link: https://lkml.kernel.org/r/20250108014723.166637-1-shr@devkernel.io
      [shr@devkernel.io: v3]
        Link: https://lkml.kernel.org/r/20250109063411.6591-1-shr@devkernel.io
      Link: https://lkml.kernel.org/r/20250104012037.159386-1-shr@devkernel.io
      
      
      Signed-off-by: default avatarStefan Roesch <shr@devkernel.io>
      Reported-by: default avatarcheung wall <zzqq0103.hey@gmail.com>
      Closes: https://lore.kernel.org/linux-mm/87pll35yd0.fsf@devkernel.io/T/#t
      
      
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Qiang Zhang <zzqq0103.hey@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4ce718f3
    • Juergen Gross's avatar
      x86/execmem: fix ROX cache usage in Xen PV guests · 59f59108
      Juergen Gross authored
      The recently introduced ROX cache for modules is assuming large page
      support in 64-bit mode without testing the related feature bit.  This
      results in breakage when running as a Xen PV guest, as in this mode large
      pages are not supported.
      
      Fix that by testing the X86_FEATURE_PSE capability when deciding whether
      to enable the ROX cache.
      
      Link: https://lkml.kernel.org/r/20250103065631.26459-1-jgross@suse.com
      Fixes: 2e45474a
      
       ("execmem: add support for cache of large ROX pages")
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      59f59108
    • Marco Nelissen's avatar
      filemap: avoid truncating 64-bit offset to 32 bits · f505e6c9
      Marco Nelissen authored
      On 32-bit kernels, folio_seek_hole_data() was inadvertently truncating a
      64-bit value to 32 bits, leading to a possible infinite loop when writing
      to an xfs filesystem.
      
      Link: https://lkml.kernel.org/r/20250102190540.1356838-1-marco.nelissen@gmail.com
      Fixes: 54fa39ac
      
       ("iomap: use mapping_seek_hole_data")
      Signed-off-by: default avatarMarco Nelissen <marco.nelissen@gmail.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      f505e6c9
    • Suren Baghdasaryan's avatar
      tools: fix atomic_set() definition to set the value correctly · 4bbb6df6
      Suren Baghdasaryan authored
      Currently vma test is failing because of the new vma_assert_attached()
      assertion.  The check is failing because previous refcount_set() inside
      vma_mark_attached() is a NoOp.  Fix the definition of atomic_set() to
      correctly set the value of the atomic.
      
      Link: https://lkml.kernel.org/r/20241227222220.1726384-1-surenb@google.com
      Fixes: 9325b8b5
      
       ("tools: add skeleton code for userland testing of VMA logic")
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Reviewed-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4bbb6df6
    • Honggyu Kim's avatar
      mm/mempolicy: count MPOL_WEIGHTED_INTERLEAVE to "interleave_hit" · 264a88ca
      Honggyu Kim authored
      Commit fa3bea4e introduced MPOL_WEIGHTED_INTERLEAVE but it missed
      adding its counter to "interleave_hit" of numastat, which is located at
      /sys/devices/system/node/nodeN/ directory.
      
      It'd be better to add weighted interleving counter info to the existing
      "interleave_hit" instead of introducing a new counter
      "weighted_interleave_hit".
      
      Link: https://lkml.kernel.org/r/20241227095737.645-1-honggyu.kim@sk.com
      Fixes: fa3bea4e
      
       ("mm/mempolicy: introduce MPOL_WEIGHTED_INTERLEAVE for weighted interleaving")
      Signed-off-by: default avatarHonggyu Kim <honggyu.kim@sk.com>
      Reviewed-by: default avatarGregory Price <gourry@gourry.net>
      Reviewed-by: default avatarHyeonggon Yoo <hyeonggon.yoo@sk.com>
      Tested-by: default avatarYunjeong Mun <yunjeong.mun@sk.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      264a88ca
    • Luca Ceresoli's avatar
      scripts/decode_stacktrace.sh: fix decoding of lines with an additional info · 2bff77c6
      Luca Ceresoli authored
      Since commit bdf8eafb ("arm64: stacktrace: report source of unwind
      data") a stack trace line can contain an additional info field that was not
      present before, in the form of one or more letters in parentheses. E.g.:
      
        [  504.517915]  led_sysfs_enable+0x54/0x80 (P)
                                                   ^^^
      
      When this is present, decode_stacktrace decodes the line incorrectly:
      
        [  504.517915] led_sysfs_enable+0x54/0x80 P
      
      Extend parsing to decode it correctly:
      
        [  504.517915] led_sysfs_enable (drivers/leds/led-core.c:455 (discriminator 7)) (P)
      
      The regex to match such lines assumes the info can be extended in the
      future to other uppercase characters, and will need to be extended in case
      other characters will be used. Using a much more generic regex might incur
      in false positives, so this looked like a good tradeoff.
      
      Link: https://lkml.kernel.org/r/20241230-decode_stacktrace-fix-info-v1-1-984910659173@bootlin.com
      Fixes: bdf8eafb
      
       ("arm64: stacktrace: report source of unwind data")
      Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Puranjay Mohan <puranjay@kernel.org>
      Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      2bff77c6
    • Guo Weikang's avatar
      mm/kmemleak: fix percpu memory leak detection failure · 76d5d4c5
      Guo Weikang authored
      kmemleak_alloc_percpu gives an incorrect min_count parameter, causing
      percpu memory to be considered a gray object.
      
      Link: https://lkml.kernel.org/r/20241227092311.3572500-1-guoweikang.kernel@gmail.com
      Fixes: 8c868592
      
       ("mm/kmemleak: use IS_ERR_PCPU() for pointer in the percpu address space")
      Signed-off-by: default avatarGuo Weikang <guoweikang.kernel@gmail.com>
      Acked-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Guo Weikang <guoweikang.kernel@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      76d5d4c5
    • Linus Torvalds's avatar
      Linux 6.13-rc7 · 5bc55a33
      Linus Torvalds authored
      v6.13-rc7
      5bc55a33
    • Linus Torvalds's avatar
      Merge tag 'char-misc-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · 0cbe1047
      Linus Torvalds authored
      Pull char/misc/IIO driver fixes from Greg KH:
       "Here are a bunch of small IIO and interconnect and other driver fixes
        to resolve reported issues. Included in here are:
      
         - loads of iio driver fixes as a result of an audit of places where
          uninitialized data would leak to userspace.
      
         - other smaller, and normal, iio driver fixes.
      
         - mhi driver fix
      
         - interconnect driver fixes
      
         - pci1xxxx driver fix
      
        All of these have been in linux-next for a while with no reported
        issues"
      
      * tag 'char-misc-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (32 commits)
        misc: microchip: pci1xxxx: Resolve return code mismatch during GPIO set config
        misc: microchip: pci1xxxx: Resolve kernel panic during GPIO IRQ handling
        interconnect: icc-clk: check return values of devm_kasprintf()
        interconnect: qcom: icc-rpm: Set the count member before accessing the flex array
        iio: adc: ti-ads1119: fix sample size in scan struct for triggered buffer
        iio: temperature: tmp006: fix information leak in triggered buffer
        iio: inkern: call iio_device_put() only on mapped devices
        iio: adc: ad9467: Fix the "don't allow reading vref if not available" case
        iio: adc: at91: call input_free_device() on allocated iio_dev
        iio: adc: ad7173: fix using shared static info struct
        iio: adc: ti-ads124s08: Use gpiod_set_value_cansleep()
        iio: adc: ti-ads1119: fix information leak in triggered buffer
        iio: pressure: zpa2326: fix information leak in triggered buffer
        iio: adc: rockchip_saradc: fix information leak in triggered buffer
        iio: imu: kmx61: fix information leak in triggered buffer
        iio: light: vcnl4035: fix information leak in triggered buffer
        iio: light: bh1745: fix information leak in triggered buffer
        iio: adc: ti-ads8688: fix information leak in triggered buffer
        iio: dummy: iio_simply_dummy_buffer: fix information leak in triggered buffer
        iio: test: Fix GTS test config
        ...
      0cbe1047
    • Linus Torvalds's avatar
      Merge tag 'driver-core-6.13-rc7' of... · 083f9fac
      Linus Torvalds authored
      Merge tag 'driver-core-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
      
      Pull driver core and debugfs fixes from Greg KH:
       "Here are some small driver core and debugfs fixes that resolve some
        reported problems:
      
         - debugfs runtime error reporting fixes
      
         - topology cpumask race-condition fix
      
         - MAINTAINERS file email update
      
        All of these have been in linux-next this week with no reported
        issues"
      
      * tag 'driver-core-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
        fs: debugfs: fix open proxy for unsafe files
        MAINTAINERS: align Danilo's maintainer entries
        topology: Keep the cpumask unchanged when printing cpumap
        debugfs: fix missing mutex_destroy() in short_fops case
        fs: debugfs: differentiate short fops with proxy ops
      083f9fac
    • Linus Torvalds's avatar
      Merge tag 'staging-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 91fff6fa
      Linus Torvalds authored
      Pull staging driver fixes from Greg KH:
       "Here are some small staging driver fixes that resolve some reported
        issues and have been in my tree for too long due to the holiday break.
        They resolve the following issues:
      
         - lots of gpib build-time fixes as reported by testers and 0-day
      
         - gpib logical fixes
      
         - mailmap fix
      
        All of these have been in linux-next for a while, with no reported
        issues other than the duplicated change"
      
      * tag 'staging-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
        staging: gpib: mite: remove unused global functions
        staging: gpib: refer to correct config symbol in tnt4882 Makefile
        mailmap: update Bingwu Zhang's email address
        staging: gpib: fix address space mixup
        staging: gpib: use ioport_map
        staging: gpib: fix pcmcia dependencies
        staging: gpib: add module author and description fields
        staging: gpib: fix Makefiles
        staging: gpib: make global 'usec_diff' functions static
        staging: gpib: Modify mismatched function name
        staging: gpib: Add lower bound check for secondary address
        staging: gpib: Fix erroneous removal of blank before newline
      91fff6fa
    • Linus Torvalds's avatar
      Merge tag 'tty-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 4bd9e3b4
      Linus Torvalds authored
      Pull serial driver fixes from Greg KH:
       "Here are three small serial driver fixes tree. They resolve some
        reported issues:
      
         - stm32 break control fix
      
         - 8250 runtime pm usage counter fix
      
         - imx driver locking fix
      
        All have been in my tree and linux-next for three weeks now, with no
        reported issues"
      
      * tag 'tty-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        serial: stm32: use port lock wrappers for break control
        serial: imx: Use uart_port_lock_irq() instead of uart_port_lock()
        tty: serial: 8250: Fix another runtime PM usage counter underflow
      4bd9e3b4
    • Linus Torvalds's avatar
      Merge tag 'usb-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 196856db
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some small USB driver fixes and new device ids for 6.13-rc7.
        Included in here are:
      
         - usb serial new device ids
      
         - typec bugfixes for reported issues
      
         - dwc3 driver fixes
      
         - chipidea driver fixes
      
         - gadget driver fixes
      
         - other minor fixes for reported problems.
      
        All of these have been in linux-next for a while, with no reported
        issues"
      
      * tag 'usb-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        USB: serial: option: add Neoway N723-EA support
        USB: serial: option: add MeiG Smart SRM815
        USB: serial: cp210x: add Phoenix Contact UPS Device
        usb: typec: fix pm usage counter imbalance in ucsi_ccg_sync_control()
        usb-storage: Add max sectors quirk for Nokia 208
        usb: gadget: midi2: Reverse-select at the right place
        usb: gadget: f_fs: Remove WARN_ON in functionfs_bind
        USB: core: Disable LPM only for non-suspended ports
        usb: fix reference leak in usb_new_device()
        usb: typec: tcpci: fix NULL pointer issue on shared irq case
        usb: gadget: u_serial: Disable ep before setting port to null to fix the crash caused by port being null
        usb: chipidea: ci_hdrc_imx: decrement device's refcount in .remove() and in the error path of .probe()
        usb: typec: ucsi: Set orientation as none when connector is unplugged
        usb: gadget: configfs: Ignore trailing LF for user strings to cdev
        USB: usblp: return error when setting unsupported protocol
        usb: gadget: f_uac2: Fix incorrect setting of bNumEndpoints
        usb: typec: tcpm/tcpci_maxim: fix error code in max_contaminant_read_resistance_kohm()
        usb: host: xhci-plat: set skip_phy_initialization if software node has XHCI_SKIP_PHY_INIT property
        usb: dwc3-am62: Disable autosuspend during remove
        usb: dwc3: gadget: fix writing NYET threshold
      196856db
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · be548645
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "The largest part here is for KVM/PPC, where a NULL pointer dereference
        was introduced in the 6.13 merge window and is now fixed.
      
        There's some "holiday-induced lateness", as the s390 submaintainer put
        it, but otherwise things looks fine.
      
        s390:
      
         - fix a latent bug when the kernel is compiled in debug mode
      
         - two small UCONTROL fixes and their selftests
      
        arm64:
      
         - always check page state in hyp_ack_unshare()
      
         - align set_id_regs selftest with the fact that ASIDBITS field is RO
      
         - various vPMU fixes for bugs that only affect nested virt
      
        PPC e500:
      
         - Fix a mostly impossible (but just wrong) case where IRQs were never
           re-enabled
      
         - Observe host permissions instead of mapping readonly host pages as
           guest-writable. This fixes a NULL-pointer dereference in 6.13
      
         - Replace brittle VMA-based attempts at building huge shadow TLB
           entries with PTE lookups"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: e500: perform hugepage check after looking up the PFN
        KVM: e500: map readonly host pages for read
        KVM: e500: track host-writability of pages
        KVM: e500: use shadow TLB entry as witness for writability
        KVM: e500: always restore irqs
        KVM: s390: selftests: Add has device attr check to uc_attr_mem_limit selftest
        KVM: s390: selftests: Add ucontrol gis routing test
        KVM: s390: Reject KVM_SET_GSI_ROUTING on ucontrol VMs
        KVM: s390: selftests: Add ucontrol flic attr selftests
        KVM: s390: Reject setting flic pfault attributes on ucontrol VMs
        KVM: s390: vsie: fix virtual/physical address in unpin_scb()
        KVM: arm64: Only apply PMCR_EL0.P to the guest range of counters
        KVM: arm64: nv: Reload PMU events upon MDCR_EL2.HPME change
        KVM: arm64: Use KVM_REQ_RELOAD_PMU to handle PMCR_EL0.E change
        KVM: arm64: Add unified helper for reprogramming counters by mask
        KVM: arm64: Always check the state from hyp_ack_unshare()
        KVM: arm64: Fix set_id_regs selftest for ASIDBITS becoming unwritable
      be548645
    • Linus Torvalds's avatar
      Merge tag 'perf_urgent_for_v6.13_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · a603abe3
      Linus Torvalds authored
      Pull perf fix from Borislav Petkov:
      
       - Fix a #GP in the perf user callchain code caused by a race between
         uprobe freeing the task and the bpf profiler unwinding the task's
         user stack
      
      * tag 'perf_urgent_for_v6.13_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        uprobes: Fix race in uprobe_free_utask
      a603abe3
    • Linus Torvalds's avatar
      Merge tag 'x86_urgent_for_v6.13_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · f31acaef
      Linus Torvalds authored
      Pull x86 fixes from Borislav Petkov:
      
       - Check whether shadow stack is active before using the ptrace regset
         getter
      
       - Remove a wrong BUG_ON in the early static call code which breaks Xen
         PVH when booting as dom0
      
      * tag 'x86_urgent_for_v6.13_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/fpu: Ensure shadow stack is active before "getting" registers
        x86/static-call: Remove early_boot_irqs_disabled check to fix Xen PVH dom0
      f31acaef
    • Paolo Bonzini's avatar
      Merge tag 'kvm-s390-master-6.13-1' of... · a5546c2f
      Paolo Bonzini authored
      Merge tag 'kvm-s390-master-6.13-1' of https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
      
      KVM: s390: three small bugfixes
      
      Fix a latent bug when the kernel is compiled in debug mode.
      Two small UCONTROL fixes and their selftests.
      a5546c2f
    • Paolo Bonzini's avatar
      Merge tag 'kvmarm-fixes-6.13-3' of... · 5c99a684
      Paolo Bonzini authored
      Merge tag 'kvmarm-fixes-6.13-3' of https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
      
      KVM/arm64 changes for 6.13, part #3
      
       - Always check page state in hyp_ack_unshare()
      
       - Align set_id_regs selftest with the fact that ASIDBITS field is RO
      
       - Various vPMU fixes for bugs that only affect nested virt
      5c99a684
    • Paolo Bonzini's avatar
      Merge branch 'kvm-e500-check-writable-pfn' into HEAD · 71b7bf17
      Paolo Bonzini authored
      The new __kvm_faultin_pfn() function is upset by the fact that e500
      KVM ignores host page permissions - __kvm_faultin requires a "writable"
      outgoing argument, but e500 KVM is passing NULL.
      
      While a simple fix would be possible that simply allows writable to
      be NULL, it is quite ugly to have e500 KVM ignore completely the host
      permissions and map readonly host pages as guest-writable.  Merge a more
      complete fix and remove the VMA-based attempts at building huge shadow TLB
      entries.  Using a PTE lookup, similar to what is done for x86, is better
      and works with remap_pfn_range() because it does not assume that VM_PFNMAP
      areas are contiguous.  Note that the same incorrect logic is there in
      ARM's get_vma_page_shift() and RISC-V's kvm_riscv_gstage_ioremap().
      
      Fortunately, for e500 most of the code is already there; it just has to
      be changed to compute the range from find_linux_pte()'s output rather
      than find_vma().  The new code works for both VM_PFNMAP and hugetlb
      mappings, so the latter is removed.
      
      Patches 2-5 were tested by the reporter, Christian Zigotzky.  Since
      the difference with v1 is minimal, I am going to send it to Linus
      today.
      71b7bf17
    • Paolo Bonzini's avatar
      KVM: e500: perform hugepage check after looking up the PFN · 55f4db79
      Paolo Bonzini authored
      
      e500 KVM tries to bypass __kvm_faultin_pfn() in order to map VM_PFNMAP
      VMAs as huge pages.  This is a Bad Idea because VM_PFNMAP VMAs could
      become noncontiguous as a result of callsto remap_pfn_range().
      
      Instead, use the already existing host PTE lookup to retrieve a
      valid host-side mapping level after __kvm_faultin_pfn() has
      returned.  Then find the largest size that will satisfy the
      guest's request while staying within a single host PTE.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      55f4db79
    • Paolo Bonzini's avatar
      KVM: e500: map readonly host pages for read · 03b755b2
      Paolo Bonzini authored
      
      The new __kvm_faultin_pfn() function is upset by the fact that e500 KVM
      ignores host page permissions - __kvm_faultin requires a "writable"
      outgoing argument, but e500 KVM is nonchalantly passing NULL.
      
      If the host page permissions do not include writability, the shadow
      TLB entry is forcibly mapped read-only.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      03b755b2
    • Paolo Bonzini's avatar
      KVM: e500: track host-writability of pages · f2104bf2
      Paolo Bonzini authored
      
      Add the possibility of marking a page so that the UW and SW bits are
      force-cleared.  This is stored in the private info so that it persists
      across multiple calls to kvmppc_e500_setup_stlbe.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f2104bf2
    • Paolo Bonzini's avatar
      KVM: e500: use shadow TLB entry as witness for writability · e97fbb43
      Paolo Bonzini authored
      
      kvmppc_e500_ref_setup is returning whether the guest TLB entry is writable,
      which is than passed to kvm_release_faultin_page.  This makes little sense
      for two reasons: first, because the function sets up the private data for
      the page and the return value feels like it has been bolted on the side;
      second, because what really matters is whether the _shadow_ TLB entry is
      writable.  If it is not writable, the page can be released as non-dirty.
      Shift from using tlbe_is_writable(gtlbe) to doing the same check on
      the shadow TLB entry.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e97fbb43
    • Paolo Bonzini's avatar
      KVM: e500: always restore irqs · 87ecfdbc
      Paolo Bonzini authored
      
      If find_linux_pte fails, IRQs will not be restored.  This is unlikely
      to happen in practice since it would have been reported as hanging
      hosts, but it should of course be fixed anyway.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      87ecfdbc