Skip to content

Commit

Permalink
Merge tag 'mm-hotfixes-stable-2023-03-04-13-12' of git://git.kernel.o…
Browse files Browse the repository at this point in the history
…rg/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
  • Loading branch information
torvalds committed Mar 4, 2023
2 parents c29214b + ecf1d92 commit 20fdfd5
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 82 deletions.
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Dengcheng Zhu <[email protected]> <[email protected]>
Dengcheng Zhu <[email protected]> <[email protected]>
Dengcheng Zhu <[email protected]> <[email protected]>
<[email protected]> <[email protected]>
Dikshita Agarwal <[email protected]> <[email protected]>
Dmitry Baryshkov <[email protected]>
Dmitry Baryshkov <[email protected]> <[[email protected]]>
Dmitry Baryshkov <[email protected]> <[email protected]>
Expand Down Expand Up @@ -150,6 +151,7 @@ Gao Xiang <[email protected]> <[email protected]>
Gao Xiang <[email protected]> <[email protected]>
Gao Xiang <[email protected]> <[email protected]>
Gao Xiang <[email protected]> <[email protected]>
Georgi Djakov <[email protected]> <[email protected]>
Gerald Schaefer <[email protected]> <[email protected]>
Gerald Schaefer <[email protected]> <[email protected]>
Gerald Schaefer <[email protected]> <[email protected]>
Expand Down Expand Up @@ -441,6 +443,7 @@ Vasily Averin <[email protected]> <[email protected]>
Vasily Averin <[email protected]> <[email protected]>
Vasily Averin <[email protected]> <[email protected]>
Valentin Schneider <[email protected]> <[email protected]>
Vikash Garodia <[email protected]> <[email protected]>
Vinod Koul <[email protected]> <[email protected]>
Vinod Koul <[email protected]> <[email protected]>
Vinod Koul <[email protected]> <[email protected]>
Expand Down
19 changes: 0 additions & 19 deletions arch/x86/include/asm/string_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,6 @@ char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);
int strcmp(const char *cs, const char *ct);

#if (defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__))
/*
* For files that not instrumented (e.g. mm/slub.c) we
* should use not instrumented version of mem* functions.
*/

#undef memcpy
#define memcpy(dst, src, len) __memcpy(dst, src, len)
#undef memmove
#define memmove(dst, src, len) __memmove(dst, src, len)
#undef memset
#define memset(s, c, n) __memset(s, c, n)

#ifndef __NO_FORTIFY
#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
#endif

#endif

#ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
#define __HAVE_ARCH_MEMCPY_FLUSHCACHE 1
void __memcpy_flushcache(void *dst, const void *src, size_t cnt);
Expand Down
2 changes: 1 addition & 1 deletion fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
unsigned int len)
{
struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
struct file_ra_state ra;
struct file_ra_state ra = {};
struct page *pages[BLKS_PER_BUF];
unsigned i, blocknr, buffer;
unsigned long devsize;
Expand Down
4 changes: 2 additions & 2 deletions fs/hfsplus/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ static void hfsplus_put_super(struct super_block *sb)
hfsplus_sync_fs(sb, 1);
}

iput(sbi->alloc_file);
iput(sbi->hidden_dir);
hfs_btree_close(sbi->attr_tree);
hfs_btree_close(sbi->cat_tree);
hfs_btree_close(sbi->ext_tree);
iput(sbi->alloc_file);
iput(sbi->hidden_dir);
kfree(sbi->s_vhdr_buf);
kfree(sbi->s_backup_vhdr_buf);
unload_nls(sbi->nls);
Expand Down
34 changes: 13 additions & 21 deletions fs/ocfs2/move_extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ static int __ocfs2_move_extent(handle_t *handle,
*/
replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED;

ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode),
context->et.et_root_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret) {
mlog_errno(ret);
goto out;
}

ret = ocfs2_split_extent(handle, &context->et, path, index,
&replace_rec, context->meta_ac,
&context->dealloc);
Expand All @@ -121,8 +113,6 @@ static int __ocfs2_move_extent(handle_t *handle,
goto out;
}

ocfs2_journal_dirty(handle, context->et.et_root_bh);

context->new_phys_cpos = new_p_cpos;

/*
Expand Down Expand Up @@ -444,7 +434,7 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
bg = (struct ocfs2_group_desc *)gd_bh->b_data;

if (vict_blkno < (le64_to_cpu(bg->bg_blkno) +
le16_to_cpu(bg->bg_bits))) {
(le16_to_cpu(bg->bg_bits) << bits_per_unit))) {

*ret_bh = gd_bh;
*vict_bit = (vict_blkno - blkno) >>
Expand Down Expand Up @@ -559,6 +549,7 @@ static void ocfs2_probe_alloc_group(struct inode *inode, struct buffer_head *bh,
last_free_bits++;

if (last_free_bits == move_len) {
i -= move_len;
*goal_bit = i;
*phys_cpos = base_cpos + i;
break;
Expand Down Expand Up @@ -1030,18 +1021,19 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)

context->range = &range;

/*
* ok, the default theshold for the defragmentation
* is 1M, since our maximum clustersize was 1M also.
* any thought?
*/
if (!range.me_threshold)
range.me_threshold = 1024 * 1024;

if (range.me_threshold > i_size_read(inode))
range.me_threshold = i_size_read(inode);

if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) {
context->auto_defrag = 1;
/*
* ok, the default theshold for the defragmentation
* is 1M, since our maximum clustersize was 1M also.
* any thought?
*/
if (!range.me_threshold)
range.me_threshold = 1024 * 1024;

if (range.me_threshold > i_size_read(inode))
range.me_threshold = i_size_read(inode);

if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG)
context->partial = 1;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/rmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ enum ttu_flags {
TTU_SPLIT_HUGE_PMD = 0x4, /* split huge PMD if any */
TTU_IGNORE_MLOCK = 0x8, /* ignore mlock */
TTU_SYNC = 0x10, /* avoid racy checks with PVMW_SYNC */
TTU_IGNORE_HWPOISON = 0x20, /* corrupted page is recoverable */
TTU_HWPOISON = 0x20, /* do convert pte to hwpoison entry */
TTU_BATCH_FLUSH = 0x40, /* Batch TLB flushes where possible
* and caller guarantees they will
* do a final flush if necessary */
Expand Down
44 changes: 26 additions & 18 deletions kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ static void panic_print_sys_info(bool console_flush)
return;
}

if (panic_print & PANIC_PRINT_ALL_CPU_BT)
trigger_all_cpu_backtrace();

if (panic_print & PANIC_PRINT_TASK_INFO)
show_state();

Expand Down Expand Up @@ -244,6 +241,30 @@ void check_panic_on_warn(const char *origin)
origin, limit);
}

/*
* Helper that triggers the NMI backtrace (if set in panic_print)
* and then performs the secondary CPUs shutdown - we cannot have
* the NMI backtrace after the CPUs are off!
*/
static void panic_other_cpus_shutdown(bool crash_kexec)
{
if (panic_print & PANIC_PRINT_ALL_CPU_BT)
trigger_all_cpu_backtrace();

/*
* Note that smp_send_stop() is the usual SMP shutdown function,
* which unfortunately may not be hardened to work in a panic
* situation. If we want to do crash dump after notifier calls
* and kmsg_dump, we will need architecture dependent extra
* bits in addition to stopping other CPUs, hence we rely on
* crash_smp_send_stop() for that.
*/
if (!crash_kexec)
smp_send_stop();
else
crash_smp_send_stop();
}

/**
* panic - halt the system
* @fmt: The text string to print
Expand Down Expand Up @@ -334,23 +355,10 @@ void panic(const char *fmt, ...)
*
* Bypass the panic_cpu check and call __crash_kexec directly.
*/
if (!_crash_kexec_post_notifiers) {
if (!_crash_kexec_post_notifiers)
__crash_kexec(NULL);

/*
* Note smp_send_stop is the usual smp shutdown function, which
* unfortunately means it may not be hardened to work in a
* panic situation.
*/
smp_send_stop();
} else {
/*
* If we want to do crash dump after notifier calls and
* kmsg_dump, we will need architecture dependent extra
* works in addition to stopping other CPUs.
*/
crash_smp_send_stop();
}
panic_other_cpus_shutdown(_crash_kexec_post_notifiers);

/*
* Run any panic handlers, including those that might need to
Expand Down
9 changes: 9 additions & 0 deletions lib/Kconfig.kasan
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ menuconfig KASAN

if KASAN

config CC_HAS_KASAN_MEMINTRINSIC_PREFIX
def_bool (CC_IS_CLANG && $(cc-option,-fsanitize=kernel-address -mllvm -asan-kernel-mem-intrinsic-prefix=1)) || \
(CC_IS_GCC && $(cc-option,-fsanitize=kernel-address --param asan-kernel-mem-intrinsic-prefix=1))
# Don't define it if we don't need it: compilation of the test uses
# this variable to decide how the compiler should treat builtins.
depends on !KASAN_HW_TAGS
help
The compiler is able to prefix memintrinsics with __asan or __hwasan.

choice
prompt "KASAN mode"
default KASAN_GENERIC
Expand Down
14 changes: 7 additions & 7 deletions lib/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ EXPORT_SYMBOL(match_token);
* as a number in that base.
*
* Return: On success, sets @result to the integer represented by the
* string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* string and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
static int match_number(substring_t *s, int *result, int base)
{
Expand Down Expand Up @@ -165,7 +165,7 @@ static int match_number(substring_t *s, int *result, int base)
* as a number in that base.
*
* Return: On success, sets @result to the integer represented by the
* string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* string and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
static int match_u64int(substring_t *s, u64 *result, int base)
{
Expand All @@ -189,7 +189,7 @@ static int match_u64int(substring_t *s, u64 *result, int base)
* Description: Attempts to parse the &substring_t @s as a decimal integer.
*
* Return: On success, sets @result to the integer represented by the string
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
int match_int(substring_t *s, int *result)
{
Expand All @@ -205,7 +205,7 @@ EXPORT_SYMBOL(match_int);
* Description: Attempts to parse the &substring_t @s as a decimal integer.
*
* Return: On success, sets @result to the integer represented by the string
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
int match_uint(substring_t *s, unsigned int *result)
{
Expand All @@ -228,7 +228,7 @@ EXPORT_SYMBOL(match_uint);
* integer.
*
* Return: On success, sets @result to the integer represented by the string
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
int match_u64(substring_t *s, u64 *result)
{
Expand All @@ -244,7 +244,7 @@ EXPORT_SYMBOL(match_u64);
* Description: Attempts to parse the &substring_t @s as an octal integer.
*
* Return: On success, sets @result to the integer represented by the string
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
int match_octal(substring_t *s, int *result)
{
Expand All @@ -260,7 +260,7 @@ EXPORT_SYMBOL(match_octal);
* Description: Attempts to parse the &substring_t @s as a hexadecimal integer.
*
* Return: On success, sets @result to the integer represented by the string
* and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
* and returns 0. Returns -EINVAL or -ERANGE on failure.
*/
int match_hex(substring_t *s, int *result)
{
Expand Down
4 changes: 3 additions & 1 deletion lib/zlib_deflate/defutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,11 @@ static inline void flush_pending(
z_streamp strm
)
{
unsigned len;
deflate_state *s = (deflate_state *) strm->state;
unsigned len = s->pending;

bi_flush(s);
len = s->pending;
if (len > strm->avail_out) len = strm->avail_out;
if (len == 0) return;

Expand Down
7 changes: 3 additions & 4 deletions mm/damon/paddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,11 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
folio_put(folio);
continue;
}
if (folio_test_unevictable(folio)) {
if (folio_test_unevictable(folio))
folio_putback_lru(folio);
} else {
else
list_add(&folio->lru, &folio_list);
folio_put(folio);
}
folio_put(folio);
}
applied = reclaim_pages(&folio_list);
cond_resched();
Expand Down
9 changes: 8 additions & 1 deletion mm/kasan/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ CFLAGS_shadow.o := $(CC_FLAGS_KASAN_RUNTIME)
CFLAGS_hw_tags.o := $(CC_FLAGS_KASAN_RUNTIME)
CFLAGS_sw_tags.o := $(CC_FLAGS_KASAN_RUNTIME)

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

CFLAGS_kasan_test.o := $(CFLAGS_KASAN_TEST)
CFLAGS_kasan_test_module.o := $(CFLAGS_KASAN_TEST)
Expand Down
4 changes: 4 additions & 0 deletions mm/kasan/kasan.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,4 +666,8 @@ void __hwasan_storeN_noabort(unsigned long addr, size_t size);

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

void *__hwasan_memset(void *addr, int c, size_t len);
void *__hwasan_memmove(void *dest, const void *src, size_t len);
void *__hwasan_memcpy(void *dest, const void *src, size_t len);

#endif /* __MM_KASAN_KASAN_H */
Loading

0 comments on commit 20fdfd5

Please sign in to comment.