Skip to content

Commit 3c339db

Browse files
committed
Merge tag 'mm-hotfixes-stable-2022-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc hotfixes from Andrew Morton: "Eight fix pre-6.0 bugs and the remainder address issues which were introduced in the 6.1-rc merge cycle, or address issues which aren't considered sufficiently serious to warrant a -stable backport" * tag 'mm-hotfixes-stable-2022-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (23 commits) mm: multi-gen LRU: move lru_gen_add_mm() out of IRQ-off region lib: maple_tree: remove unneeded initialization in mtree_range_walk() mmap: fix remap_file_pages() regression mm/shmem: ensure proper fallback if page faults mm/userfaultfd: replace kmap/kmap_atomic() with kmap_local_page() x86: fortify: kmsan: fix KMSAN fortify builds x86: asm: make sure __put_user_size() evaluates pointer once Kconfig.debug: disable CONFIG_FRAME_WARN for KMSAN by default x86/purgatory: disable KMSAN instrumentation mm: kmsan: export kmsan_copy_page_meta() mm: migrate: fix return value if all subpages of THPs are migrated successfully mm/uffd: fix vma check on userfault for wp mm: prep_compound_tail() clear page->private mm,madvise,hugetlb: fix unexpected data loss with MADV_DONTNEED on hugetlbfs mm/page_isolation: fix clang deadcode warning fs/ext4/super.c: remove unused `deprecated_msg' ipc/msg.c: fix percpu_counter use after free memory tier, sysfs: rename attribute "nodes" to "nodelist" MAINTAINERS: git://github.com -> https://github.com for nilfs2 mm/kmemleak: prevent soft lockup in kmemleak_scan()'s object iteration loops ...
2 parents 91562cf + dda1c41 commit 3c339db

28 files changed

+196
-68
lines changed

Documentation/ABI/testing/sysfs-kernel-mm-memory-tiers

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Description: A collection of all the memory tiers allocated.
1010

1111

1212
What: /sys/devices/virtual/memory_tiering/memory_tierN/
13-
/sys/devices/virtual/memory_tiering/memory_tierN/nodes
13+
/sys/devices/virtual/memory_tiering/memory_tierN/nodelist
1414
Date: August 2022
1515
Contact: Linux memory management mailing list <[email protected]>
1616
Description: Directory with details of a specific memory tier
@@ -21,5 +21,5 @@ Description: Directory with details of a specific memory tier
2121
A smaller value of N implies a higher (faster) memory tier in the
2222
hierarchy.
2323

24-
nodes: NUMA nodes that are part of this memory tier.
24+
nodelist: NUMA nodes that are part of this memory tier.
2525

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14523,7 +14523,7 @@ L: [email protected]
1452314523
S: Supported
1452414524
W: https://nilfs.sourceforge.io/
1452514525
W: https://nilfs.osdn.jp/
14526-
T: git git://github.com/konis/nilfs2.git
14526+
T: git https://github.com/konis/nilfs2.git
1452714527
F: Documentation/filesystems/nilfs2.rst
1452814528
F: fs/nilfs2/
1452914529
F: include/trace/events/nilfs2.h

arch/x86/include/asm/string_64.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
/* Even with __builtin_ the compiler may decide to use the out of line
1111
function. */
1212

13+
#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
14+
#include <linux/kmsan_string.h>
15+
#endif
16+
1317
#define __HAVE_ARCH_MEMCPY 1
14-
#if defined(__SANITIZE_MEMORY__)
18+
#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
1519
#undef memcpy
16-
void *__msan_memcpy(void *dst, const void *src, size_t size);
1720
#define memcpy __msan_memcpy
1821
#else
1922
extern void *memcpy(void *to, const void *from, size_t len);
2023
#endif
2124
extern void *__memcpy(void *to, const void *from, size_t len);
2225

2326
#define __HAVE_ARCH_MEMSET
24-
#if defined(__SANITIZE_MEMORY__)
27+
#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
2528
extern void *__msan_memset(void *s, int c, size_t n);
2629
#undef memset
2730
#define memset __msan_memset
@@ -67,7 +70,7 @@ static inline void *memset64(uint64_t *s, uint64_t v, size_t n)
6770
}
6871

6972
#define __HAVE_ARCH_MEMMOVE
70-
#if defined(__SANITIZE_MEMORY__)
73+
#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
7174
#undef memmove
7275
void *__msan_memmove(void *dest, const void *src, size_t len);
7376
#define memmove __msan_memmove

arch/x86/include/asm/uaccess.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,25 @@ extern void __put_user_nocheck_8(void);
254254
#define __put_user_size(x, ptr, size, label) \
255255
do { \
256256
__typeof__(*(ptr)) __x = (x); /* eval x once */ \
257-
__chk_user_ptr(ptr); \
257+
__typeof__(ptr) __ptr = (ptr); /* eval ptr once */ \
258+
__chk_user_ptr(__ptr); \
258259
switch (size) { \
259260
case 1: \
260-
__put_user_goto(__x, ptr, "b", "iq", label); \
261+
__put_user_goto(__x, __ptr, "b", "iq", label); \
261262
break; \
262263
case 2: \
263-
__put_user_goto(__x, ptr, "w", "ir", label); \
264+
__put_user_goto(__x, __ptr, "w", "ir", label); \
264265
break; \
265266
case 4: \
266-
__put_user_goto(__x, ptr, "l", "ir", label); \
267+
__put_user_goto(__x, __ptr, "l", "ir", label); \
267268
break; \
268269
case 8: \
269-
__put_user_goto_u64(__x, ptr, label); \
270+
__put_user_goto_u64(__x, __ptr, label); \
270271
break; \
271272
default: \
272273
__put_user_bad(); \
273274
} \
274-
instrument_put_user(__x, ptr, size); \
275+
instrument_put_user(__x, __ptr, size); \
275276
} while (0)
276277

277278
#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT

arch/x86/purgatory/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ GCOV_PROFILE := n
2626
KASAN_SANITIZE := n
2727
UBSAN_SANITIZE := n
2828
KCSAN_SANITIZE := n
29+
KMSAN_SANITIZE := n
2930
KCOV_INSTRUMENT := n
3031

3132
# These are adjustments to the compiler flags used for objects that

fs/exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,6 @@ static int exec_mmap(struct mm_struct *mm)
10121012
active_mm = tsk->active_mm;
10131013
tsk->active_mm = mm;
10141014
tsk->mm = mm;
1015-
lru_gen_add_mm(mm);
10161015
/*
10171016
* This prevents preemption while active_mm is being loaded and
10181017
* it and mm are being updated, which could cause problems for
@@ -1025,6 +1024,7 @@ static int exec_mmap(struct mm_struct *mm)
10251024
activate_mm(active_mm, mm);
10261025
if (IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM))
10271026
local_irq_enable();
1027+
lru_gen_add_mm(mm);
10281028
task_unlock(tsk);
10291029
lru_gen_use_mm(mm);
10301030
if (old_mm) {

fs/ext4/super.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,6 @@ static const struct fs_parameter_spec ext4_param_specs[] = {
17411741

17421742
#define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
17431743

1744-
static const char deprecated_msg[] =
1745-
"Mount option \"%s\" will be removed by %s\n"
1746-
"Contact [email protected] if you think we should keep it.\n";
1747-
17481744
#define MOPT_SET 0x0001
17491745
#define MOPT_CLEAR 0x0002
17501746
#define MOPT_NOSUPPORT 0x0004

fs/squashfs/file.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,9 @@ static int squashfs_readahead_fragment(struct page **page,
506506
squashfs_i(inode)->fragment_size);
507507
struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
508508
unsigned int n, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
509+
int error = buffer->error;
509510

510-
if (buffer->error)
511+
if (error)
511512
goto out;
512513

513514
expected += squashfs_i(inode)->fragment_offset;
@@ -529,7 +530,7 @@ static int squashfs_readahead_fragment(struct page **page,
529530

530531
out:
531532
squashfs_cache_put(buffer);
532-
return buffer->error;
533+
return error;
533534
}
534535

535536
static void squashfs_readahead(struct readahead_control *ractl)
@@ -557,6 +558,13 @@ static void squashfs_readahead(struct readahead_control *ractl)
557558
int res, bsize;
558559
u64 block = 0;
559560
unsigned int expected;
561+
struct page *last_page;
562+
563+
expected = start >> msblk->block_log == file_end ?
564+
(i_size_read(inode) & (msblk->block_size - 1)) :
565+
msblk->block_size;
566+
567+
max_pages = (expected + PAGE_SIZE - 1) >> PAGE_SHIFT;
560568

561569
nr_pages = __readahead_batch(ractl, pages, max_pages);
562570
if (!nr_pages)
@@ -566,13 +574,10 @@ static void squashfs_readahead(struct readahead_control *ractl)
566574
goto skip_pages;
567575

568576
index = pages[0]->index >> shift;
577+
569578
if ((pages[nr_pages - 1]->index >> shift) != index)
570579
goto skip_pages;
571580

572-
expected = index == file_end ?
573-
(i_size_read(inode) & (msblk->block_size - 1)) :
574-
msblk->block_size;
575-
576581
if (index == file_end && squashfs_i(inode)->fragment_block !=
577582
SQUASHFS_INVALID_BLK) {
578583
res = squashfs_readahead_fragment(pages, nr_pages,
@@ -593,15 +598,15 @@ static void squashfs_readahead(struct readahead_control *ractl)
593598

594599
res = squashfs_read_data(inode->i_sb, block, bsize, NULL, actor);
595600

596-
squashfs_page_actor_free(actor);
601+
last_page = squashfs_page_actor_free(actor);
597602

598603
if (res == expected) {
599604
int bytes;
600605

601606
/* Last page (if present) may have trailing bytes not filled */
602607
bytes = res % PAGE_SIZE;
603-
if (pages[nr_pages - 1]->index == file_end && bytes)
604-
memzero_page(pages[nr_pages - 1], bytes,
608+
if (index == file_end && bytes && last_page)
609+
memzero_page(last_page, bytes,
605610
PAGE_SIZE - bytes);
606611

607612
for (i = 0; i < nr_pages; i++) {

fs/squashfs/page_actor.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ static void *handle_next_page(struct squashfs_page_actor *actor)
7171
(actor->next_index != actor->page[actor->next_page]->index)) {
7272
actor->next_index++;
7373
actor->returned_pages++;
74+
actor->last_page = NULL;
7475
return actor->alloc_buffer ? actor->tmp_buffer : ERR_PTR(-ENOMEM);
7576
}
7677

7778
actor->next_index++;
7879
actor->returned_pages++;
80+
actor->last_page = actor->page[actor->next_page];
7981
return actor->pageaddr = kmap_local_page(actor->page[actor->next_page++]);
8082
}
8183

@@ -125,6 +127,7 @@ struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_
125127
actor->returned_pages = 0;
126128
actor->next_index = page[0]->index & ~((1 << (msblk->block_log - PAGE_SHIFT)) - 1);
127129
actor->pageaddr = NULL;
130+
actor->last_page = NULL;
128131
actor->alloc_buffer = msblk->decompressor->alloc_buffer;
129132
actor->squashfs_first_page = direct_first_page;
130133
actor->squashfs_next_page = direct_next_page;

fs/squashfs/page_actor.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct squashfs_page_actor {
1616
void *(*squashfs_first_page)(struct squashfs_page_actor *);
1717
void *(*squashfs_next_page)(struct squashfs_page_actor *);
1818
void (*squashfs_finish_page)(struct squashfs_page_actor *);
19+
struct page *last_page;
1920
int pages;
2021
int length;
2122
int next_page;
@@ -29,10 +30,13 @@ extern struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
2930
extern struct squashfs_page_actor *squashfs_page_actor_init_special(
3031
struct squashfs_sb_info *msblk,
3132
struct page **page, int pages, int length);
32-
static inline void squashfs_page_actor_free(struct squashfs_page_actor *actor)
33+
static inline struct page *squashfs_page_actor_free(struct squashfs_page_actor *actor)
3334
{
35+
struct page *last_page = actor->last_page;
36+
3437
kfree(actor->tmp_buffer);
3538
kfree(actor);
39+
return last_page;
3640
}
3741
static inline void *squashfs_first_page(struct squashfs_page_actor *actor)
3842
{

0 commit comments

Comments
 (0)