Skip to content

Commit 20fdfd5

Browse files
committed
Merge tag 'mm-hotfixes-stable-2023-03-04-13-12' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "17 hotfixes. Eight are for MM and seven are for other parts of the kernel. Seven are cc:stable and eight address post-6.3 issues or were judged unsuitable for -stable backporting" * tag 'mm-hotfixes-stable-2023-03-04-13-12' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mailmap: map Dikshita Agarwal's old address to his current one mailmap: map Vikash Garodia's old address to his current one fs/cramfs/inode.c: initialize file_ra_state fs: hfsplus: fix UAF issue in hfsplus_put_super panic: fix the panic_print NMI backtrace setting lib: parser: update documentation for match_NUMBER functions kasan, x86: don't rename memintrinsics in uninstrumented files kasan: test: fix test for new meminstrinsic instrumentation kasan: treat meminstrinsic as builtins in uninstrumented files kasan: emit different calls for instrumentable memintrinsics ocfs2: fix non-auto defrag path not working issue ocfs2: fix defrag path triggering jbd2 ASSERT mailmap: map Georgi Djakov's old Linaro address to his current one mm/hwpoison: convert TTU_IGNORE_HWPOISON to TTU_HWPOISON lib/zlib: DFLTCC deflate does not write all available bits for Z_NO_FLUSH mm/damon/paddr: fix missing folio_put() mm/mremap: fix dup_anon_vma() in vma_merge() case 4
2 parents c29214b + ecf1d92 commit 20fdfd5

File tree

19 files changed

+147
-82
lines changed

19 files changed

+147
-82
lines changed

.mailmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Dengcheng Zhu <[email protected]> <[email protected]>
121121
122122
123123
124+
124125
Dmitry Baryshkov <[email protected]>
125126
Dmitry Baryshkov <[email protected]> <[[email protected]]>
126127
@@ -150,6 +151,7 @@ Gao Xiang <[email protected]> <[email protected]>
150151
151152
152153
154+
153155
154156
155157
@@ -441,6 +443,7 @@ Vasily Averin <[email protected]> <[email protected]>
441443
442444
443445
Valentin Schneider <[email protected]> <[email protected]>
446+
444447
445448
446449

arch/x86/include/asm/string_64.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,6 @@ char *strcpy(char *dest, const char *src);
8585
char *strcat(char *dest, const char *src);
8686
int strcmp(const char *cs, const char *ct);
8787

88-
#if (defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__))
89-
/*
90-
* For files that not instrumented (e.g. mm/slub.c) we
91-
* should use not instrumented version of mem* functions.
92-
*/
93-
94-
#undef memcpy
95-
#define memcpy(dst, src, len) __memcpy(dst, src, len)
96-
#undef memmove
97-
#define memmove(dst, src, len) __memmove(dst, src, len)
98-
#undef memset
99-
#define memset(s, c, n) __memset(s, c, n)
100-
101-
#ifndef __NO_FORTIFY
102-
#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
103-
#endif
104-
105-
#endif
106-
10788
#ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
10889
#define __HAVE_ARCH_MEMCPY_FLUSHCACHE 1
10990
void __memcpy_flushcache(void *dst, const void *src, size_t cnt);

fs/cramfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
183183
unsigned int len)
184184
{
185185
struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
186-
struct file_ra_state ra;
186+
struct file_ra_state ra = {};
187187
struct page *pages[BLKS_PER_BUF];
188188
unsigned i, blocknr, buffer;
189189
unsigned long devsize;

fs/hfsplus/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ static void hfsplus_put_super(struct super_block *sb)
295295
hfsplus_sync_fs(sb, 1);
296296
}
297297

298+
iput(sbi->alloc_file);
299+
iput(sbi->hidden_dir);
298300
hfs_btree_close(sbi->attr_tree);
299301
hfs_btree_close(sbi->cat_tree);
300302
hfs_btree_close(sbi->ext_tree);
301-
iput(sbi->alloc_file);
302-
iput(sbi->hidden_dir);
303303
kfree(sbi->s_vhdr_buf);
304304
kfree(sbi->s_backup_vhdr_buf);
305305
unload_nls(sbi->nls);

fs/ocfs2/move_extents.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ static int __ocfs2_move_extent(handle_t *handle,
105105
*/
106106
replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED;
107107

108-
ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode),
109-
context->et.et_root_bh,
110-
OCFS2_JOURNAL_ACCESS_WRITE);
111-
if (ret) {
112-
mlog_errno(ret);
113-
goto out;
114-
}
115-
116108
ret = ocfs2_split_extent(handle, &context->et, path, index,
117109
&replace_rec, context->meta_ac,
118110
&context->dealloc);
@@ -121,8 +113,6 @@ static int __ocfs2_move_extent(handle_t *handle,
121113
goto out;
122114
}
123115

124-
ocfs2_journal_dirty(handle, context->et.et_root_bh);
125-
126116
context->new_phys_cpos = new_p_cpos;
127117

128118
/*
@@ -444,7 +434,7 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
444434
bg = (struct ocfs2_group_desc *)gd_bh->b_data;
445435

446436
if (vict_blkno < (le64_to_cpu(bg->bg_blkno) +
447-
le16_to_cpu(bg->bg_bits))) {
437+
(le16_to_cpu(bg->bg_bits) << bits_per_unit))) {
448438

449439
*ret_bh = gd_bh;
450440
*vict_bit = (vict_blkno - blkno) >>
@@ -559,6 +549,7 @@ static void ocfs2_probe_alloc_group(struct inode *inode, struct buffer_head *bh,
559549
last_free_bits++;
560550

561551
if (last_free_bits == move_len) {
552+
i -= move_len;
562553
*goal_bit = i;
563554
*phys_cpos = base_cpos + i;
564555
break;
@@ -1030,18 +1021,19 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
10301021

10311022
context->range = &range;
10321023

1024+
/*
1025+
* ok, the default theshold for the defragmentation
1026+
* is 1M, since our maximum clustersize was 1M also.
1027+
* any thought?
1028+
*/
1029+
if (!range.me_threshold)
1030+
range.me_threshold = 1024 * 1024;
1031+
1032+
if (range.me_threshold > i_size_read(inode))
1033+
range.me_threshold = i_size_read(inode);
1034+
10331035
if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) {
10341036
context->auto_defrag = 1;
1035-
/*
1036-
* ok, the default theshold for the defragmentation
1037-
* is 1M, since our maximum clustersize was 1M also.
1038-
* any thought?
1039-
*/
1040-
if (!range.me_threshold)
1041-
range.me_threshold = 1024 * 1024;
1042-
1043-
if (range.me_threshold > i_size_read(inode))
1044-
range.me_threshold = i_size_read(inode);
10451037

10461038
if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG)
10471039
context->partial = 1;

include/linux/rmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ enum ttu_flags {
9494
TTU_SPLIT_HUGE_PMD = 0x4, /* split huge PMD if any */
9595
TTU_IGNORE_MLOCK = 0x8, /* ignore mlock */
9696
TTU_SYNC = 0x10, /* avoid racy checks with PVMW_SYNC */
97-
TTU_IGNORE_HWPOISON = 0x20, /* corrupted page is recoverable */
97+
TTU_HWPOISON = 0x20, /* do convert pte to hwpoison entry */
9898
TTU_BATCH_FLUSH = 0x40, /* Batch TLB flushes where possible
9999
* and caller guarantees they will
100100
* do a final flush if necessary */

kernel/panic.c

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,6 @@ static void panic_print_sys_info(bool console_flush)
212212
return;
213213
}
214214

215-
if (panic_print & PANIC_PRINT_ALL_CPU_BT)
216-
trigger_all_cpu_backtrace();
217-
218215
if (panic_print & PANIC_PRINT_TASK_INFO)
219216
show_state();
220217

@@ -244,6 +241,30 @@ void check_panic_on_warn(const char *origin)
244241
origin, limit);
245242
}
246243

244+
/*
245+
* Helper that triggers the NMI backtrace (if set in panic_print)
246+
* and then performs the secondary CPUs shutdown - we cannot have
247+
* the NMI backtrace after the CPUs are off!
248+
*/
249+
static void panic_other_cpus_shutdown(bool crash_kexec)
250+
{
251+
if (panic_print & PANIC_PRINT_ALL_CPU_BT)
252+
trigger_all_cpu_backtrace();
253+
254+
/*
255+
* Note that smp_send_stop() is the usual SMP shutdown function,
256+
* which unfortunately may not be hardened to work in a panic
257+
* situation. If we want to do crash dump after notifier calls
258+
* and kmsg_dump, we will need architecture dependent extra
259+
* bits in addition to stopping other CPUs, hence we rely on
260+
* crash_smp_send_stop() for that.
261+
*/
262+
if (!crash_kexec)
263+
smp_send_stop();
264+
else
265+
crash_smp_send_stop();
266+
}
267+
247268
/**
248269
* panic - halt the system
249270
* @fmt: The text string to print
@@ -334,23 +355,10 @@ void panic(const char *fmt, ...)
334355
*
335356
* Bypass the panic_cpu check and call __crash_kexec directly.
336357
*/
337-
if (!_crash_kexec_post_notifiers) {
358+
if (!_crash_kexec_post_notifiers)
338359
__crash_kexec(NULL);
339360

340-
/*
341-
* Note smp_send_stop is the usual smp shutdown function, which
342-
* unfortunately means it may not be hardened to work in a
343-
* panic situation.
344-
*/
345-
smp_send_stop();
346-
} else {
347-
/*
348-
* If we want to do crash dump after notifier calls and
349-
* kmsg_dump, we will need architecture dependent extra
350-
* works in addition to stopping other CPUs.
351-
*/
352-
crash_smp_send_stop();
353-
}
361+
panic_other_cpus_shutdown(_crash_kexec_post_notifiers);
354362

355363
/*
356364
* Run any panic handlers, including those that might need to

lib/Kconfig.kasan

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ menuconfig KASAN
4949

5050
if KASAN
5151

52+
config CC_HAS_KASAN_MEMINTRINSIC_PREFIX
53+
def_bool (CC_IS_CLANG && $(cc-option,-fsanitize=kernel-address -mllvm -asan-kernel-mem-intrinsic-prefix=1)) || \
54+
(CC_IS_GCC && $(cc-option,-fsanitize=kernel-address --param asan-kernel-mem-intrinsic-prefix=1))
55+
# Don't define it if we don't need it: compilation of the test uses
56+
# this variable to decide how the compiler should treat builtins.
57+
depends on !KASAN_HW_TAGS
58+
help
59+
The compiler is able to prefix memintrinsics with __asan or __hwasan.
60+
5261
choice
5362
prompt "KASAN mode"
5463
default KASAN_GENERIC

lib/parser.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ EXPORT_SYMBOL(match_token);
133133
* as a number in that base.
134134
*
135135
* Return: On success, sets @result to the integer represented by the
136-
* string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
136+
* string and returns 0. Returns -EINVAL or -ERANGE on failure.
137137
*/
138138
static int match_number(substring_t *s, int *result, int base)
139139
{
@@ -165,7 +165,7 @@ static int match_number(substring_t *s, int *result, int base)
165165
* as a number in that base.
166166
*
167167
* Return: On success, sets @result to the integer represented by the
168-
* string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
168+
* string and returns 0. Returns -EINVAL or -ERANGE on failure.
169169
*/
170170
static int match_u64int(substring_t *s, u64 *result, int base)
171171
{
@@ -189,7 +189,7 @@ static int match_u64int(substring_t *s, u64 *result, int base)
189189
* Description: Attempts to parse the &substring_t @s as a decimal integer.
190190
*
191191
* Return: On success, sets @result to the integer represented by the string
192-
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
192+
* and returns 0. Returns -EINVAL or -ERANGE on failure.
193193
*/
194194
int match_int(substring_t *s, int *result)
195195
{
@@ -205,7 +205,7 @@ EXPORT_SYMBOL(match_int);
205205
* Description: Attempts to parse the &substring_t @s as a decimal integer.
206206
*
207207
* Return: On success, sets @result to the integer represented by the string
208-
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
208+
* and returns 0. Returns -EINVAL or -ERANGE on failure.
209209
*/
210210
int match_uint(substring_t *s, unsigned int *result)
211211
{
@@ -228,7 +228,7 @@ EXPORT_SYMBOL(match_uint);
228228
* integer.
229229
*
230230
* Return: On success, sets @result to the integer represented by the string
231-
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
231+
* and returns 0. Returns -EINVAL or -ERANGE on failure.
232232
*/
233233
int match_u64(substring_t *s, u64 *result)
234234
{
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(match_u64);
244244
* Description: Attempts to parse the &substring_t @s as an octal integer.
245245
*
246246
* Return: On success, sets @result to the integer represented by the string
247-
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
247+
* and returns 0. Returns -EINVAL or -ERANGE on failure.
248248
*/
249249
int match_octal(substring_t *s, int *result)
250250
{
@@ -260,7 +260,7 @@ EXPORT_SYMBOL(match_octal);
260260
* Description: Attempts to parse the &substring_t @s as a hexadecimal integer.
261261
*
262262
* Return: On success, sets @result to the integer represented by the string
263-
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
263+
* and returns 0. Returns -EINVAL or -ERANGE on failure.
264264
*/
265265
int match_hex(substring_t *s, int *result)
266266
{

lib/zlib_deflate/defutil.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,11 @@ static inline void flush_pending(
420420
z_streamp strm
421421
)
422422
{
423+
unsigned len;
423424
deflate_state *s = (deflate_state *) strm->state;
424-
unsigned len = s->pending;
425425

426+
bi_flush(s);
427+
len = s->pending;
426428
if (len > strm->avail_out) len = strm->avail_out;
427429
if (len == 0) return;
428430

mm/damon/paddr.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,11 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
250250
folio_put(folio);
251251
continue;
252252
}
253-
if (folio_test_unevictable(folio)) {
253+
if (folio_test_unevictable(folio))
254254
folio_putback_lru(folio);
255-
} else {
255+
else
256256
list_add(&folio->lru, &folio_list);
257-
folio_put(folio);
258-
}
257+
folio_put(folio);
259258
}
260259
applied = reclaim_pages(&folio_list);
261260
cond_resched();

mm/kasan/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ CFLAGS_shadow.o := $(CC_FLAGS_KASAN_RUNTIME)
3535
CFLAGS_hw_tags.o := $(CC_FLAGS_KASAN_RUNTIME)
3636
CFLAGS_sw_tags.o := $(CC_FLAGS_KASAN_RUNTIME)
3737

38-
CFLAGS_KASAN_TEST := $(CFLAGS_KASAN) -fno-builtin $(call cc-disable-warning, vla)
38+
CFLAGS_KASAN_TEST := $(CFLAGS_KASAN) $(call cc-disable-warning, vla)
39+
ifndef CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX
40+
# If compiler instruments memintrinsics by prefixing them with __asan/__hwasan,
41+
# we need to treat them normally (as builtins), otherwise the compiler won't
42+
# recognize them as instrumentable. If it doesn't instrument them, we need to
43+
# pass -fno-builtin, so the compiler doesn't inline them.
44+
CFLAGS_KASAN_TEST += -fno-builtin
45+
endif
3946

4047
CFLAGS_kasan_test.o := $(CFLAGS_KASAN_TEST)
4148
CFLAGS_kasan_test_module.o := $(CFLAGS_KASAN_TEST)

mm/kasan/kasan.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,8 @@ void __hwasan_storeN_noabort(unsigned long addr, size_t size);
666666

667667
void __hwasan_tag_memory(unsigned long addr, u8 tag, unsigned long size);
668668

669+
void *__hwasan_memset(void *addr, int c, size_t len);
670+
void *__hwasan_memmove(void *dest, const void *src, size_t len);
671+
void *__hwasan_memcpy(void *dest, const void *src, size_t len);
672+
669673
#endif /* __MM_KASAN_KASAN_H */

0 commit comments

Comments
 (0)