Skip to content

Commit 5635d8b

Browse files
committed
Merge tag 'mm-hotfixes-stable-2025-01-04-18-02' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull hotfixes from Andrew Morton: "25 hotfixes. 16 are cc:stable. 18 are MM and 7 are non-MM. The usual bunch of singletons and two doubletons - please see the relevant changelogs for details" * tag 'mm-hotfixes-stable-2025-01-04-18-02' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (25 commits) MAINTAINERS: change Arınç _NAL's name and email address scripts/sorttable: fix orc_sort_cmp() to maintain symmetry and transitivity mm/util: make memdup_user_nul() similar to memdup_user() mm, madvise: fix potential workingset node list_lru leaks mm/damon/core: fix ignored quota goals and filters of newly committed schemes mm/damon/core: fix new damon_target objects leaks on damon_commit_targets() mm/list_lru: fix false warning of negative counter vmstat: disable vmstat_work on vmstat_cpu_down_prep() mm: shmem: fix the update of 'shmem_falloc->nr_unswapped' mm: shmem: fix incorrect index alignment for within_size policy percpu: remove intermediate variable in PERCPU_PTR() mm: zswap: fix race between [de]compression and CPU hotunplug ocfs2: fix slab-use-after-free due to dangling pointer dqi_priv fs/proc/task_mmu: fix pagemap flags with PMD THP entries on 32bit kcov: mark in_softirq_really() as __always_inline docs: mm: fix the incorrect 'FileHugeMapped' field mailmap: modify the entry for Mathieu Othacehe mm/kmemleak: fix sleeping function called from invalid context at print message mm: hugetlb: independent PMD page table shared count maple_tree: reload mas before the second call for mas_empty_area ...
2 parents 7a5b6fc + e740492 commit 5635d8b

File tree

29 files changed

+212
-69
lines changed

29 files changed

+212
-69
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Martin Kepplinger <martink@posteo.de> <martin.kepplinger@ginzinger.com>
435435
Martin Kepplinger <martink@posteo.de> <martin.kepplinger@puri.sm>
436436
Martin Kepplinger <martink@posteo.de> <martin.kepplinger@theobroma-systems.com>
437437
Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com> <martyna.szapar-mudlaw@intel.com>
438-
Mathieu Othacehe <m.othacehe@gmail.com> <othacehe@gnu.org>
438+
Mathieu Othacehe <othacehe@gnu.org> <m.othacehe@gmail.com>
439439
Mat Martineau <martineau@kernel.org> <mathew.j.martineau@linux.intel.com>
440440
Mat Martineau <martineau@kernel.org> <mathewm@codeaurora.org>
441441
Matthew Wilcox <willy@infradead.org> <matthew.r.wilcox@intel.com>

Documentation/admin-guide/mm/transhuge.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ AnonHugePmdMapped).
436436
The number of file transparent huge pages mapped to userspace is available
437437
by reading ShmemPmdMapped and ShmemHugePages fields in ``/proc/meminfo``.
438438
To identify what applications are mapping file transparent huge pages, it
439-
is necessary to read ``/proc/PID/smaps`` and count the FileHugeMapped fields
439+
is necessary to read ``/proc/PID/smaps`` and count the FilePmdMapped fields
440440
for each mapping.
441441

442442
Note that reading the smaps file is expensive and reading it

MAINTAINERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14756,7 +14756,7 @@ F: drivers/memory/mtk-smi.c
1475614756
F: include/soc/mediatek/smi.h
1475714757

1475814758
MEDIATEK SWITCH DRIVER
14759-
M: Arınç ÜNAL <arinc.unal@arinc9.com>
14759+
M: Chester A. Unal <chester.a.unal@arinc9.com>
1476014760
M: Daniel Golle <daniel@makrotopia.org>
1476114761
M: DENG Qingfang <dqfext@gmail.com>
1476214762
M: Sean Wang <sean.wang@mediatek.com>
@@ -18460,7 +18460,7 @@ F: Documentation/devicetree/bindings/pinctrl/mediatek,mt8183-pinctrl.yaml
1846018460
F: drivers/pinctrl/mediatek/
1846118461

1846218462
PIN CONTROLLER - MEDIATEK MIPS
18463-
M: Arınç ÜNAL <arinc.unal@arinc9.com>
18463+
M: Chester A. Unal <chester.a.unal@arinc9.com>
1846418464
M: Sergio Paracuellos <sergio.paracuellos@gmail.com>
1846518465
L: linux-mediatek@lists.infradead.org (moderated for non-subscribers)
1846618466
L: linux-mips@vger.kernel.org
@@ -19504,7 +19504,7 @@ S: Maintained
1950419504
F: arch/mips/ralink
1950519505

1950619506
RALINK MT7621 MIPS ARCHITECTURE
19507-
M: Arınç ÜNAL <arinc.unal@arinc9.com>
19507+
M: Chester A. Unal <chester.a.unal@arinc9.com>
1950819508
M: Sergio Paracuellos <sergio.paracuellos@gmail.com>
1950919509
L: linux-mips@vger.kernel.org
1951019510
S: Maintained

fs/ocfs2/quota_global.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ static int ocfs2_get_next_id(struct super_block *sb, struct kqid *qid)
893893
int status = 0;
894894

895895
trace_ocfs2_get_next_id(from_kqid(&init_user_ns, *qid), type);
896-
if (!sb_has_quota_loaded(sb, type)) {
896+
if (!sb_has_quota_active(sb, type)) {
897897
status = -ESRCH;
898898
goto out;
899899
}

fs/ocfs2/quota_local.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ static int ocfs2_local_free_info(struct super_block *sb, int type)
867867
brelse(oinfo->dqi_libh);
868868
brelse(oinfo->dqi_lqi_bh);
869869
kfree(oinfo);
870+
info->dqi_priv = NULL;
870871
return status;
871872
}
872873

fs/proc/task_mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,7 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
18101810
}
18111811

18121812
for (; addr != end; addr += PAGE_SIZE, idx++) {
1813-
unsigned long cur_flags = flags;
1813+
u64 cur_flags = flags;
18141814
pagemap_entry_t pme;
18151815

18161816
if (folio && (flags & PM_PRESENT) &&

include/linux/memfd.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifdef CONFIG_MEMFD_CREATE
88
extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg);
99
struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx);
10+
unsigned int *memfd_file_seals_ptr(struct file *file);
1011
#else
1112
static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
1213
{
@@ -16,6 +17,19 @@ static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
1617
{
1718
return ERR_PTR(-EINVAL);
1819
}
20+
21+
static inline unsigned int *memfd_file_seals_ptr(struct file *file)
22+
{
23+
return NULL;
24+
}
1925
#endif
2026

27+
/* Retrieve memfd seals associated with the file, if any. */
28+
static inline unsigned int memfd_file_seals(struct file *file)
29+
{
30+
unsigned int *sealsp = memfd_file_seals_ptr(file);
31+
32+
return sealsp ? *sealsp : 0;
33+
}
34+
2135
#endif /* __LINUX_MEMFD_H */

include/linux/mm.h

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,7 @@ static inline bool pagetable_pmd_ctor(struct ptdesc *ptdesc)
31253125
if (!pmd_ptlock_init(ptdesc))
31263126
return false;
31273127
__folio_set_pgtable(folio);
3128+
ptdesc_pmd_pts_init(ptdesc);
31283129
lruvec_stat_add_folio(folio, NR_PAGETABLE);
31293130
return true;
31303131
}
@@ -4101,6 +4102,37 @@ void mem_dump_obj(void *object);
41014102
static inline void mem_dump_obj(void *object) {}
41024103
#endif
41034104

4105+
static inline bool is_write_sealed(int seals)
4106+
{
4107+
return seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE);
4108+
}
4109+
4110+
/**
4111+
* is_readonly_sealed - Checks whether write-sealed but mapped read-only,
4112+
* in which case writes should be disallowing moving
4113+
* forwards.
4114+
* @seals: the seals to check
4115+
* @vm_flags: the VMA flags to check
4116+
*
4117+
* Returns whether readonly sealed, in which case writess should be disallowed
4118+
* going forward.
4119+
*/
4120+
static inline bool is_readonly_sealed(int seals, vm_flags_t vm_flags)
4121+
{
4122+
/*
4123+
* Since an F_SEAL_[FUTURE_]WRITE sealed memfd can be mapped as
4124+
* MAP_SHARED and read-only, take care to not allow mprotect to
4125+
* revert protections on such mappings. Do this only for shared
4126+
* mappings. For private mappings, don't need to mask
4127+
* VM_MAYWRITE as we still want them to be COW-writable.
4128+
*/
4129+
if (is_write_sealed(seals) &&
4130+
((vm_flags & (VM_SHARED | VM_WRITE)) == VM_SHARED))
4131+
return true;
4132+
4133+
return false;
4134+
}
4135+
41044136
/**
41054137
* seal_check_write - Check for F_SEAL_WRITE or F_SEAL_FUTURE_WRITE flags and
41064138
* handle them.
@@ -4112,24 +4144,15 @@ static inline void mem_dump_obj(void *object) {}
41124144
*/
41134145
static inline int seal_check_write(int seals, struct vm_area_struct *vma)
41144146
{
4115-
if (seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE)) {
4116-
/*
4117-
* New PROT_WRITE and MAP_SHARED mmaps are not allowed when
4118-
* write seals are active.
4119-
*/
4120-
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
4121-
return -EPERM;
4122-
4123-
/*
4124-
* Since an F_SEAL_[FUTURE_]WRITE sealed memfd can be mapped as
4125-
* MAP_SHARED and read-only, take care to not allow mprotect to
4126-
* revert protections on such mappings. Do this only for shared
4127-
* mappings. For private mappings, don't need to mask
4128-
* VM_MAYWRITE as we still want them to be COW-writable.
4129-
*/
4130-
if (vma->vm_flags & VM_SHARED)
4131-
vm_flags_clear(vma, VM_MAYWRITE);
4132-
}
4147+
if (!is_write_sealed(seals))
4148+
return 0;
4149+
4150+
/*
4151+
* New PROT_WRITE and MAP_SHARED mmaps are not allowed when
4152+
* write seals are active.
4153+
*/
4154+
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
4155+
return -EPERM;
41334156

41344157
return 0;
41354158
}

include/linux/mm_types.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ FOLIO_MATCH(compound_head, _head_2a);
445445
* @pt_index: Used for s390 gmap.
446446
* @pt_mm: Used for x86 pgds.
447447
* @pt_frag_refcount: For fragmented page table tracking. Powerpc only.
448+
* @pt_share_count: Used for HugeTLB PMD page table share count.
448449
* @_pt_pad_2: Padding to ensure proper alignment.
449450
* @ptl: Lock for the page table.
450451
* @__page_type: Same as page->page_type. Unused for page tables.
@@ -471,6 +472,9 @@ struct ptdesc {
471472
pgoff_t pt_index;
472473
struct mm_struct *pt_mm;
473474
atomic_t pt_frag_refcount;
475+
#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
476+
atomic_t pt_share_count;
477+
#endif
474478
};
475479

476480
union {
@@ -516,6 +520,32 @@ static_assert(sizeof(struct ptdesc) <= sizeof(struct page));
516520
const struct page *: (const struct ptdesc *)(p), \
517521
struct page *: (struct ptdesc *)(p)))
518522

523+
#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
524+
static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc)
525+
{
526+
atomic_set(&ptdesc->pt_share_count, 0);
527+
}
528+
529+
static inline void ptdesc_pmd_pts_inc(struct ptdesc *ptdesc)
530+
{
531+
atomic_inc(&ptdesc->pt_share_count);
532+
}
533+
534+
static inline void ptdesc_pmd_pts_dec(struct ptdesc *ptdesc)
535+
{
536+
atomic_dec(&ptdesc->pt_share_count);
537+
}
538+
539+
static inline int ptdesc_pmd_pts_count(struct ptdesc *ptdesc)
540+
{
541+
return atomic_read(&ptdesc->pt_share_count);
542+
}
543+
#else
544+
static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc)
545+
{
546+
}
547+
#endif
548+
519549
/*
520550
* Used for sizing the vmemmap region on some architectures
521551
*/

include/linux/percpu-defs.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ do { \
221221
} while (0)
222222

223223
#define PERCPU_PTR(__p) \
224-
({ \
225-
unsigned long __pcpu_ptr = (__force unsigned long)(__p); \
226-
(typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \
227-
})
224+
(typeof(*(__p)) __force __kernel *)((__force unsigned long)(__p))
228225

229226
#ifdef CONFIG_SMP
230227

0 commit comments

Comments
 (0)