Skip to content

Commit c45323b

Browse files
committed
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
2 parents 5bc55a3 + cbc5dde commit c45323b

File tree

20 files changed

+163
-42
lines changed

20 files changed

+163
-42
lines changed

arch/x86/mm/init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,8 @@ struct execmem_info __init *execmem_arch_setup(void)
10801080

10811081
start = MODULES_VADDR + offset;
10821082

1083-
if (IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX)) {
1083+
if (IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) &&
1084+
cpu_feature_enabled(X86_FEATURE_PSE)) {
10841085
pgprot = PAGE_KERNEL_ROX;
10851086
flags = EXECMEM_KASAN_SHADOW | EXECMEM_ROX_CACHE;
10861087
} else {

drivers/block/zram/zram_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
14681468
zram->mem_pool = zs_create_pool(zram->disk->disk_name);
14691469
if (!zram->mem_pool) {
14701470
vfree(zram->table);
1471+
zram->table = NULL;
14711472
return false;
14721473
}
14731474

fs/proc/vmcore.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ static ssize_t __read_vmcore(struct iov_iter *iter, loff_t *fpos)
404404
if (!iov_iter_count(iter))
405405
return acc;
406406
}
407+
408+
cond_resched();
407409
}
408410

409411
return acc;

include/linux/module.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ void *__module_writable_address(struct module *mod, void *loc);
773773

774774
static inline void *module_writable_address(struct module *mod, void *loc)
775775
{
776-
if (!IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) || !mod)
776+
if (!IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) || !mod ||
777+
mod->state != MODULE_STATE_UNFORMED)
777778
return loc;
778779
return __module_writable_address(mod, loc);
779780
}

include/linux/userfaultfd_k.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ static inline bool vma_can_userfault(struct vm_area_struct *vma,
247247
vma_is_shmem(vma);
248248
}
249249

250+
static inline bool vma_has_uffd_without_event_remap(struct vm_area_struct *vma)
251+
{
252+
struct userfaultfd_ctx *uffd_ctx = vma->vm_userfaultfd_ctx.ctx;
253+
254+
return uffd_ctx && (uffd_ctx->features & UFFD_FEATURE_EVENT_REMAP) == 0;
255+
}
256+
250257
extern int dup_userfaultfd(struct vm_area_struct *, struct list_head *);
251258
extern void dup_userfaultfd_complete(struct list_head *);
252259
void dup_userfaultfd_fail(struct list_head *);
@@ -402,6 +409,11 @@ static inline bool userfaultfd_wp_async(struct vm_area_struct *vma)
402409
return false;
403410
}
404411

412+
static inline bool vma_has_uffd_without_event_remap(struct vm_area_struct *vma)
413+
{
414+
return false;
415+
}
416+
405417
#endif /* CONFIG_USERFAULTFD */
406418

407419
static inline bool userfaultfd_wp_use_markers(struct vm_area_struct *vma)

include/trace/events/hugetlbfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ TRACE_EVENT(hugetlbfs_alloc_inode,
2323
TP_fast_assign(
2424
__entry->dev = inode->i_sb->s_dev;
2525
__entry->ino = inode->i_ino;
26-
__entry->dir = dir->i_ino;
26+
__entry->dir = dir ? dir->i_ino : 0;
2727
__entry->mode = mode;
2828
),
2929

mm/filemap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ void folio_end_read(struct folio *folio, bool success)
15231523
/* Must be in bottom byte for x86 to work */
15241524
BUILD_BUG_ON(PG_uptodate > 7);
15251525
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
1526-
VM_BUG_ON_FOLIO(folio_test_uptodate(folio), folio);
1526+
VM_BUG_ON_FOLIO(success && folio_test_uptodate(folio), folio);
15271527

15281528
if (likely(success))
15291529
mask |= 1 << PG_uptodate;
@@ -2996,7 +2996,7 @@ static inline loff_t folio_seek_hole_data(struct xa_state *xas,
29962996
if (ops->is_partially_uptodate(folio, offset, bsz) ==
29972997
seek_data)
29982998
break;
2999-
start = (start + bsz) & ~(bsz - 1);
2999+
start = (start + bsz) & ~((u64)bsz - 1);
30003000
offset += bsz;
30013001
} while (offset < folio_size(folio));
30023002
unlock:

mm/huge_memory.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,16 @@ static pmd_t move_soft_dirty_pmd(pmd_t pmd)
22062206
return pmd;
22072207
}
22082208

2209+
static pmd_t clear_uffd_wp_pmd(pmd_t pmd)
2210+
{
2211+
if (pmd_present(pmd))
2212+
pmd = pmd_clear_uffd_wp(pmd);
2213+
else if (is_swap_pmd(pmd))
2214+
pmd = pmd_swp_clear_uffd_wp(pmd);
2215+
2216+
return pmd;
2217+
}
2218+
22092219
bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
22102220
unsigned long new_addr, pmd_t *old_pmd, pmd_t *new_pmd)
22112221
{
@@ -2244,6 +2254,8 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
22442254
pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
22452255
}
22462256
pmd = move_soft_dirty_pmd(pmd);
2257+
if (vma_has_uffd_without_event_remap(vma))
2258+
pmd = clear_uffd_wp_pmd(pmd);
22472259
set_pmd_at(mm, new_addr, new_pmd, pmd);
22482260
if (force_flush)
22492261
flush_pmd_tlb_range(vma, old_addr, old_addr + PMD_SIZE);

mm/hugetlb.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5402,6 +5402,7 @@ static void move_huge_pte(struct vm_area_struct *vma, unsigned long old_addr,
54025402
unsigned long new_addr, pte_t *src_pte, pte_t *dst_pte,
54035403
unsigned long sz)
54045404
{
5405+
bool need_clear_uffd_wp = vma_has_uffd_without_event_remap(vma);
54055406
struct hstate *h = hstate_vma(vma);
54065407
struct mm_struct *mm = vma->vm_mm;
54075408
spinlock_t *src_ptl, *dst_ptl;
@@ -5418,7 +5419,18 @@ static void move_huge_pte(struct vm_area_struct *vma, unsigned long old_addr,
54185419
spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);
54195420

54205421
pte = huge_ptep_get_and_clear(mm, old_addr, src_pte);
5421-
set_huge_pte_at(mm, new_addr, dst_pte, pte, sz);
5422+
5423+
if (need_clear_uffd_wp && pte_marker_uffd_wp(pte))
5424+
huge_pte_clear(mm, new_addr, dst_pte, sz);
5425+
else {
5426+
if (need_clear_uffd_wp) {
5427+
if (pte_present(pte))
5428+
pte = huge_pte_clear_uffd_wp(pte);
5429+
else if (is_swap_pte(pte))
5430+
pte = pte_swp_clear_uffd_wp(pte);
5431+
}
5432+
set_huge_pte_at(mm, new_addr, dst_pte, pte, sz);
5433+
}
54225434

54235435
if (src_ptl != dst_ptl)
54245436
spin_unlock(src_ptl);

mm/kmemleak.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ void __ref kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
10931093
pr_debug("%s(0x%px, %zu)\n", __func__, ptr, size);
10941094

10951095
if (kmemleak_enabled && ptr && !IS_ERR_PCPU(ptr))
1096-
create_object_percpu((__force unsigned long)ptr, size, 0, gfp);
1096+
create_object_percpu((__force unsigned long)ptr, size, 1, gfp);
10971097
}
10981098
EXPORT_SYMBOL_GPL(kmemleak_alloc_percpu);
10991099

0 commit comments

Comments
 (0)