Skip to content

Commit 1110ce6

Browse files
committed
Merge tag 'mm-hotfixes-stable-2025-03-08-16-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "33 hotfixes. 24 are cc:stable and the remainder address post-6.13 issues or aren't considered necessary for -stable kernels. 26 are for MM and 7 are for non-MM. - "mm: memory_failure: unmap poisoned folio during migrate properly" from Ma Wupeng fixes a couple of two year old bugs involving the migration of hwpoisoned folios. - "selftests/damon: three fixes for false results" from SeongJae Park fixes three one year old bugs in the SAMON selftest code. The remainder are singletons and doubletons. Please see the individual changelogs for details" * tag 'mm-hotfixes-stable-2025-03-08-16-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (33 commits) mm/page_alloc: fix uninitialized variable rapidio: add check for rio_add_net() in rio_scan_alloc_net() rapidio: fix an API misues when rio_add_net() fails MAINTAINERS: .mailmap: update Sumit Garg's email address Revert "mm/page_alloc.c: don't show protection in zone's ->lowmem_reserve[] for empty zone" mm: fix finish_fault() handling for large folios mm: don't skip arch_sync_kernel_mappings() in error paths mm: shmem: remove unnecessary warning in shmem_writepage() userfaultfd: fix PTE unmapping stack-allocated PTE copies userfaultfd: do not block on locking a large folio with raised refcount mm: zswap: use ATOMIC_LONG_INIT to initialize zswap_stored_pages mm: shmem: fix potential data corruption during shmem swapin mm: fix kernel BUG when userfaultfd_move encounters swapcache selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms selftests/damon/damos_quota: make real expectation of quota exceeds include/linux/log2.h: mark is_power_of_2() with __always_inline NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback mm, swap: avoid BUG_ON in relocate_cluster() mm: swap: use correct step in loop to wait all clusters in wait_for_allocation() ...
2 parents b7c90e3 + 8fe9ed4 commit 1110ce6

39 files changed

+348
-122
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ Subbaraman Narayanamurthy <quic_subbaram@quicinc.com> <subbaram@codeaurora.org>
691691
Subhash Jadavani <subhashj@codeaurora.org>
692692
Sudarshan Rajagopalan <quic_sudaraja@quicinc.com> <sudaraja@codeaurora.org>
693693
Sudeep Holla <sudeep.holla@arm.com> Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
694+
Sumit Garg <sumit.garg@kernel.org> <sumit.garg@linaro.org>
694695
Sumit Semwal <sumit.semwal@ti.com>
695696
Surabhi Vishnoi <quic_svishnoi@quicinc.com> <svishnoi@codeaurora.org>
696697
Sven Eckelmann <sven@narfation.org> <seckelmann@datto.com>

MAINTAINERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12875,7 +12875,7 @@ F: include/keys/trusted_dcp.h
1287512875
F: security/keys/trusted-keys/trusted_dcp.c
1287612876

1287712877
KEYS-TRUSTED-TEE
12878-
M: Sumit Garg <sumit.garg@linaro.org>
12878+
M: Sumit Garg <sumit.garg@kernel.org>
1287912879
L: linux-integrity@vger.kernel.org
1288012880
L: keyrings@vger.kernel.org
1288112881
S: Supported
@@ -17675,7 +17675,7 @@ F: Documentation/ABI/testing/sysfs-bus-optee-devices
1767517675
F: drivers/tee/optee/
1767617676

1767717677
OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
17678-
M: Sumit Garg <sumit.garg@linaro.org>
17678+
M: Sumit Garg <sumit.garg@kernel.org>
1767917679
L: op-tee@lists.trustedfirmware.org
1768017680
S: Maintained
1768117681
F: drivers/char/hw_random/optee-rng.c
@@ -23288,7 +23288,7 @@ F: include/media/i2c/tw9910.h
2328823288

2328923289
TEE SUBSYSTEM
2329023290
M: Jens Wiklander <jens.wiklander@linaro.org>
23291-
R: Sumit Garg <sumit.garg@linaro.org>
23291+
R: Sumit Garg <sumit.garg@kernel.org>
2329223292
L: op-tee@lists.trustedfirmware.org
2329323293
S: Maintained
2329423294
F: Documentation/ABI/testing/sysfs-class-tee

arch/arm/mm/fault-armv.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int do_adjust_pte(struct vm_area_struct *vma, unsigned long address,
6262
}
6363

6464
static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
65-
unsigned long pfn, struct vm_fault *vmf)
65+
unsigned long pfn, bool need_lock)
6666
{
6767
spinlock_t *ptl;
6868
pgd_t *pgd;
@@ -99,12 +99,11 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
9999
if (!pte)
100100
return 0;
101101

102-
/*
103-
* If we are using split PTE locks, then we need to take the page
104-
* lock here. Otherwise we are using shared mm->page_table_lock
105-
* which is already locked, thus cannot take it.
106-
*/
107-
if (ptl != vmf->ptl) {
102+
if (need_lock) {
103+
/*
104+
* Use nested version here to indicate that we are already
105+
* holding one similar spinlock.
106+
*/
108107
spin_lock_nested(ptl, SINGLE_DEPTH_NESTING);
109108
if (unlikely(!pmd_same(pmdval, pmdp_get_lockless(pmd)))) {
110109
pte_unmap_unlock(pte, ptl);
@@ -114,7 +113,7 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
114113

115114
ret = do_adjust_pte(vma, address, pfn, pte);
116115

117-
if (ptl != vmf->ptl)
116+
if (need_lock)
118117
spin_unlock(ptl);
119118
pte_unmap(pte);
120119

@@ -123,9 +122,10 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
123122

124123
static void
125124
make_coherent(struct address_space *mapping, struct vm_area_struct *vma,
126-
unsigned long addr, pte_t *ptep, unsigned long pfn,
127-
struct vm_fault *vmf)
125+
unsigned long addr, pte_t *ptep, unsigned long pfn)
128126
{
127+
const unsigned long pmd_start_addr = ALIGN_DOWN(addr, PMD_SIZE);
128+
const unsigned long pmd_end_addr = pmd_start_addr + PMD_SIZE;
129129
struct mm_struct *mm = vma->vm_mm;
130130
struct vm_area_struct *mpnt;
131131
unsigned long offset;
@@ -141,6 +141,14 @@ make_coherent(struct address_space *mapping, struct vm_area_struct *vma,
141141
*/
142142
flush_dcache_mmap_lock(mapping);
143143
vma_interval_tree_foreach(mpnt, &mapping->i_mmap, pgoff, pgoff) {
144+
/*
145+
* If we are using split PTE locks, then we need to take the pte
146+
* lock. Otherwise we are using shared mm->page_table_lock which
147+
* is already locked, thus cannot take it.
148+
*/
149+
bool need_lock = IS_ENABLED(CONFIG_SPLIT_PTE_PTLOCKS);
150+
unsigned long mpnt_addr;
151+
144152
/*
145153
* If this VMA is not in our MM, we can ignore it.
146154
* Note that we intentionally mask out the VMA
@@ -151,7 +159,12 @@ make_coherent(struct address_space *mapping, struct vm_area_struct *vma,
151159
if (!(mpnt->vm_flags & VM_MAYSHARE))
152160
continue;
153161
offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT;
154-
aliases += adjust_pte(mpnt, mpnt->vm_start + offset, pfn, vmf);
162+
mpnt_addr = mpnt->vm_start + offset;
163+
164+
/* Avoid deadlocks by not grabbing the same PTE lock again. */
165+
if (mpnt_addr >= pmd_start_addr && mpnt_addr < pmd_end_addr)
166+
need_lock = false;
167+
aliases += adjust_pte(mpnt, mpnt_addr, pfn, need_lock);
155168
}
156169
flush_dcache_mmap_unlock(mapping);
157170
if (aliases)
@@ -194,7 +207,7 @@ void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
194207
__flush_dcache_folio(mapping, folio);
195208
if (mapping) {
196209
if (cache_is_vivt())
197-
make_coherent(mapping, vma, addr, ptep, pfn, vmf);
210+
make_coherent(mapping, vma, addr, ptep, pfn);
198211
else if (vma->vm_flags & VM_EXEC)
199212
__flush_icache_all();
200213
}

arch/m68k/include/asm/sun3_pgalloc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ static inline pgd_t * pgd_alloc(struct mm_struct *mm)
4444
pgd_t *new_pgd;
4545

4646
new_pgd = __pgd_alloc(mm, 0);
47-
memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
48-
memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
47+
if (likely(new_pgd != NULL)) {
48+
memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
49+
memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
50+
}
4951
return new_pgd;
5052
}
5153

drivers/rapidio/devices/rio_mport_cdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,8 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
17421742
err = rio_add_net(net);
17431743
if (err) {
17441744
rmcd_debug(RDEV, "failed to register net, err=%d", err);
1745-
kfree(net);
1745+
put_device(&net->dev);
1746+
mport->net = NULL;
17461747
goto cleanup;
17471748
}
17481749
}

drivers/rapidio/rio-scan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,10 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport,
871871
dev_set_name(&net->dev, "rnet_%d", net->id);
872872
net->dev.parent = &mport->dev;
873873
net->dev.release = rio_scan_release_dev;
874-
rio_add_net(net);
874+
if (rio_add_net(net)) {
875+
put_device(&net->dev);
876+
net = NULL;
877+
}
875878
}
876879

877880
return net;

fs/nfs/file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/pagemap.h>
3030
#include <linux/gfp.h>
3131
#include <linux/swap.h>
32+
#include <linux/compaction.h>
3233

3334
#include <linux/uaccess.h>
3435
#include <linux/filelock.h>
@@ -457,7 +458,7 @@ static bool nfs_release_folio(struct folio *folio, gfp_t gfp)
457458
/* If the private flag is set, then the folio is not freeable */
458459
if (folio_test_private(folio)) {
459460
if ((current_gfp_context(gfp) & GFP_KERNEL) != GFP_KERNEL ||
460-
current_is_kswapd())
461+
current_is_kswapd() || current_is_kcompactd())
461462
return false;
462463
if (nfs_wb_folio(folio->mapping->host, folio) < 0)
463464
return false;

include/linux/compaction.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ static inline unsigned long compact_gap(unsigned int order)
8080
return 2UL << order;
8181
}
8282

83+
static inline int current_is_kcompactd(void)
84+
{
85+
return current->flags & PF_KCOMPACTD;
86+
}
87+
8388
#ifdef CONFIG_COMPACTION
8489

8590
extern unsigned int extfrag_for_order(struct zone *zone, unsigned int order);

include/linux/hugetlb.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ struct huge_bootmem_page {
682682

683683
int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list);
684684
int replace_free_hugepage_folios(unsigned long start_pfn, unsigned long end_pfn);
685+
void wait_for_freed_hugetlb_folios(void);
685686
struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
686687
unsigned long addr, bool cow_from_owner);
687688
struct folio *alloc_hugetlb_folio_nodemask(struct hstate *h, int preferred_nid,
@@ -1068,6 +1069,10 @@ static inline int replace_free_hugepage_folios(unsigned long start_pfn,
10681069
return 0;
10691070
}
10701071

1072+
static inline void wait_for_freed_hugetlb_folios(void)
1073+
{
1074+
}
1075+
10711076
static inline struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
10721077
unsigned long addr,
10731078
bool cow_from_owner)

include/linux/log2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int __ilog2_u64(u64 n)
4141
* *not* considered a power of two.
4242
* Return: true if @n is a power of 2, otherwise false.
4343
*/
44-
static inline __attribute__((const))
44+
static __always_inline __attribute__((const))
4545
bool is_power_of_2(unsigned long n)
4646
{
4747
return (n != 0 && ((n & (n - 1)) == 0));

0 commit comments

Comments
 (0)