Skip to content

Commit 28e4319

Browse files
committed
Merge tag 'mm-hotfixes-stable-2024-11-09-22-40' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "20 hotfixes, 14 of which are cc:stable. Three affect DAMON. Lorenzo's five-patch series to address the mmap_region error handling is here also. Apart from that, various singletons" * tag 'mm-hotfixes-stable-2024-11-09-22-40' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mailmap: add entry for Thorsten Blum ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove() signal: restore the override_rlimit logic fs/proc: fix compile warning about variable 'vmcore_mmap_ops' ucounts: fix counter leak in inc_rlimit_get_ucounts() selftests: hugetlb_dio: check for initial conditions to skip in the start mm: fix docs for the kernel parameter ``thp_anon=`` mm/damon/core: avoid overflow in damon_feed_loop_next_input() mm/damon/core: handle zero schemes apply interval mm/damon/core: handle zero {aggregation,ops_update} intervals mm/mlock: set the correct prev on failure objpool: fix to make percpu slot allocation more robust mm/page_alloc: keep track of free highatomic mm: resolve faulty mmap_region() error path behaviour mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling mm: refactor map_deny_write_exec() mm: unconditionally close VMAs on error mm: avoid unsafe VMA hook invocation when error arises on mmap hook mm/thp: fix deferred split unqueue naming and locking mm/thp: fix deferred split queue not partially_mapped
2 parents a558cc3 + c289f4d commit 28e4319

File tree

30 files changed

+329
-172
lines changed

30 files changed

+329
-172
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ Tomeu Vizoso <tomeu@tomeuvizoso.net> <tomeu.vizoso@collabora.com>
665665
Thomas Graf <tgraf@suug.ch>
666666
Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu>
667667
Thomas Pedersen <twp@codeaurora.org>
668+
Thorsten Blum <thorsten.blum@linux.dev> <thorsten.blum@toblux.com>
668669
Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com>
669670
Tingwei Zhang <quic_tingwei@quicinc.com> <tingwei@codeaurora.org>
670671
Tirupathi Reddy <quic_tirupath@quicinc.com> <tirupath@codeaurora.org>

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6688,7 +6688,7 @@
66886688
0: no polling (default)
66896689

66906690
thp_anon= [KNL]
6691-
Format: <size>,<size>[KMG]:<state>;<size>-<size>[KMG]:<state>
6691+
Format: <size>[KMG],<size>[KMG]:<state>;<size>[KMG]-<size>[KMG]:<state>
66926692
state is one of "always", "madvise", "never" or "inherit".
66936693
Control the default behavior of the system with respect
66946694
to anonymous transparent hugepages.

Documentation/admin-guide/mm/transhuge.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ control by passing the parameter ``transparent_hugepage=always`` or
303303
kernel command line.
304304

305305
Alternatively, each supported anonymous THP size can be controlled by
306-
passing ``thp_anon=<size>,<size>[KMG]:<state>;<size>-<size>[KMG]:<state>``,
306+
passing ``thp_anon=<size>[KMG],<size>[KMG]:<state>;<size>[KMG]-<size>[KMG]:<state>``,
307307
where ``<size>`` is the THP size (must be a power of 2 of PAGE_SIZE and
308308
supported anonymous THP) and ``<state>`` is one of ``always``, ``madvise``,
309309
``never`` or ``inherit``.

arch/arm64/include/asm/mman.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#ifndef BUILD_VDSO
88
#include <linux/compiler.h>
9+
#include <linux/fs.h>
10+
#include <linux/shmem_fs.h>
911
#include <linux/types.h>
1012

1113
static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
@@ -31,19 +33,21 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
3133
}
3234
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
3335

34-
static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
36+
static inline unsigned long arch_calc_vm_flag_bits(struct file *file,
37+
unsigned long flags)
3538
{
3639
/*
3740
* Only allow MTE on anonymous mappings as these are guaranteed to be
3841
* backed by tags-capable memory. The vm_flags may be overridden by a
3942
* filesystem supporting MTE (RAM-based).
4043
*/
41-
if (system_supports_mte() && (flags & MAP_ANONYMOUS))
44+
if (system_supports_mte() &&
45+
((flags & MAP_ANONYMOUS) || shmem_file(file)))
4246
return VM_MTE_ALLOWED;
4347

4448
return 0;
4549
}
46-
#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
50+
#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags)
4751

4852
static inline bool arch_validate_prot(unsigned long prot,
4953
unsigned long addr __always_unused)

arch/parisc/include/asm/mman.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef __ASM_MMAN_H__
33
#define __ASM_MMAN_H__
44

5+
#include <linux/fs.h>
56
#include <uapi/asm/mman.h>
67

78
/* PARISC cannot allow mdwe as it needs writable stacks */
@@ -11,7 +12,7 @@ static inline bool arch_memory_deny_write_exec_supported(void)
1112
}
1213
#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
1314

14-
static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
15+
static inline unsigned long arch_calc_vm_flag_bits(struct file *file, unsigned long flags)
1516
{
1617
/*
1718
* The stack on parisc grows upwards, so if userspace requests memory
@@ -23,6 +24,6 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
2324

2425
return 0;
2526
}
26-
#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
27+
#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags)
2728

2829
#endif /* __ASM_MMAN_H__ */

fs/ocfs2/xattr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,8 +2036,7 @@ static int ocfs2_xa_remove(struct ocfs2_xa_loc *loc,
20362036
rc = 0;
20372037
ocfs2_xa_cleanup_value_truncate(loc, "removing",
20382038
orig_clusters);
2039-
if (rc)
2040-
goto out;
2039+
goto out;
20412040
}
20422041
}
20432042

fs/proc/vmcore.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
457457
#endif
458458
}
459459

460-
static const struct vm_operations_struct vmcore_mmap_ops = {
461-
.fault = mmap_vmcore_fault,
462-
};
463-
464460
/**
465461
* vmcore_alloc_buf - allocate buffer in vmalloc memory
466462
* @size: size of buffer
@@ -488,6 +484,11 @@ static inline char *vmcore_alloc_buf(size_t size)
488484
* virtually contiguous user-space in ELF layout.
489485
*/
490486
#ifdef CONFIG_MMU
487+
488+
static const struct vm_operations_struct vmcore_mmap_ops = {
489+
.fault = mmap_vmcore_fault,
490+
};
491+
491492
/*
492493
* remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
493494
* reported as not being ram with the zero page.

include/linux/mman.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef _LINUX_MMAN_H
33
#define _LINUX_MMAN_H
44

5+
#include <linux/fs.h>
56
#include <linux/mm.h>
67
#include <linux/percpu_counter.h>
78

@@ -94,7 +95,7 @@ static inline void vm_unacct_memory(long pages)
9495
#endif
9596

9697
#ifndef arch_calc_vm_flag_bits
97-
#define arch_calc_vm_flag_bits(flags) 0
98+
#define arch_calc_vm_flag_bits(file, flags) 0
9899
#endif
99100

100101
#ifndef arch_validate_prot
@@ -151,13 +152,13 @@ calc_vm_prot_bits(unsigned long prot, unsigned long pkey)
151152
* Combine the mmap "flags" argument into "vm_flags" used internally.
152153
*/
153154
static inline unsigned long
154-
calc_vm_flag_bits(unsigned long flags)
155+
calc_vm_flag_bits(struct file *file, unsigned long flags)
155156
{
156157
return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
157158
_calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
158159
_calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
159160
_calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
160-
arch_calc_vm_flag_bits(flags);
161+
arch_calc_vm_flag_bits(file, flags);
161162
}
162163

163164
unsigned long vm_commit_limit(void);
@@ -188,16 +189,31 @@ static inline bool arch_memory_deny_write_exec_supported(void)
188189
*
189190
* d) mmap(PROT_READ | PROT_EXEC)
190191
* mmap(PROT_READ | PROT_EXEC | PROT_BTI)
192+
*
193+
* This is only applicable if the user has set the Memory-Deny-Write-Execute
194+
* (MDWE) protection mask for the current process.
195+
*
196+
* @old specifies the VMA flags the VMA originally possessed, and @new the ones
197+
* we propose to set.
198+
*
199+
* Return: false if proposed change is OK, true if not ok and should be denied.
191200
*/
192-
static inline bool map_deny_write_exec(struct vm_area_struct *vma, unsigned long vm_flags)
201+
static inline bool map_deny_write_exec(unsigned long old, unsigned long new)
193202
{
203+
/* If MDWE is disabled, we have nothing to deny. */
194204
if (!test_bit(MMF_HAS_MDWE, &current->mm->flags))
195205
return false;
196206

197-
if ((vm_flags & VM_EXEC) && (vm_flags & VM_WRITE))
207+
/* If the new VMA is not executable, we have nothing to deny. */
208+
if (!(new & VM_EXEC))
209+
return false;
210+
211+
/* Under MDWE we do not accept newly writably executable VMAs... */
212+
if (new & VM_WRITE)
198213
return true;
199214

200-
if (!(vma->vm_flags & VM_EXEC) && (vm_flags & VM_EXEC))
215+
/* ...nor previously non-executable VMAs becoming executable. */
216+
if (!(old & VM_EXEC))
201217
return true;
202218

203219
return false;

include/linux/mmzone.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ struct zone {
823823
unsigned long watermark_boost;
824824

825825
unsigned long nr_reserved_highatomic;
826+
unsigned long nr_free_highatomic;
826827

827828
/*
828829
* We don't know if the memory that we're going to allocate will be

include/linux/user_namespace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ static inline long get_rlimit_value(struct ucounts *ucounts, enum rlimit_type ty
141141

142142
long inc_rlimit_ucounts(struct ucounts *ucounts, enum rlimit_type type, long v);
143143
bool dec_rlimit_ucounts(struct ucounts *ucounts, enum rlimit_type type, long v);
144-
long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type);
144+
long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type,
145+
bool override_rlimit);
145146
void dec_rlimit_put_ucounts(struct ucounts *ucounts, enum rlimit_type type);
146147
bool is_rlimit_overlimit(struct ucounts *ucounts, enum rlimit_type type, unsigned long max);
147148

0 commit comments

Comments
 (0)