Skip to content

Commit f583772

Browse files
committed
Merge tag 'mm-hotfixes-stable-2023-12-27-15-00' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "11 hotfixes. 7 are cc:stable and the other 4 address post-6.6 issues or are not considered backporting material" * tag 'mm-hotfixes-stable-2023-12-27-15-00' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mailmap: add an old address for Naoya Horiguchi mm/memory-failure: cast index to loff_t before shifting it mm/memory-failure: check the mapcount of the precise page mm/memory-failure: pass the folio and the page to collect_procs() selftests: secretmem: floor the memory size to the multiple of page_size mm: migrate high-order folios in swap cache correctly maple_tree: do not preallocate nodes for slot stores mm/filemap: avoid buffered read/write race to read inconsistent data kunit: kasan_test: disable fortify string checker on kmalloc_oob_memset kexec: select CRYPTO from KEXEC_FILE instead of depending on it kexec: fix KEXEC_FILE dependencies
2 parents 1997b3c + 1803d0c commit f583772

File tree

13 files changed

+74
-32
lines changed

13 files changed

+74
-32
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ Muna Sinada <[email protected]> <[email protected]>
436436
437437
Mythri P K <[email protected]>
438438
Nadia Yvette Chambers <[email protected]> William Lee Irwin III <[email protected]>
439+
439440
440441
441442

arch/powerpc/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@ config ARCH_SUPPORTS_KEXEC
608608
def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
609609

610610
config ARCH_SUPPORTS_KEXEC_FILE
611-
def_bool PPC64 && CRYPTO=y && CRYPTO_SHA256=y
611+
def_bool PPC64
612612

613613
config ARCH_SUPPORTS_KEXEC_PURGATORY
614-
def_bool KEXEC_FILE
614+
def_bool y
615615

616616
config ARCH_SELECTS_KEXEC_FILE
617617
def_bool y

arch/riscv/Kconfig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,7 @@ config ARCH_SELECTS_KEXEC_FILE
702702
select KEXEC_ELF
703703

704704
config ARCH_SUPPORTS_KEXEC_PURGATORY
705-
def_bool KEXEC_FILE
706-
depends on CRYPTO=y
707-
depends on CRYPTO_SHA256=y
705+
def_bool ARCH_SUPPORTS_KEXEC_FILE
708706

709707
config ARCH_SUPPORTS_CRASH_DUMP
710708
def_bool y

arch/s390/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ config ARCH_SUPPORTS_KEXEC
254254
def_bool y
255255

256256
config ARCH_SUPPORTS_KEXEC_FILE
257-
def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390
257+
def_bool y
258258

259259
config ARCH_SUPPORTS_KEXEC_SIG
260260
def_bool MODULE_SIG_FORMAT
261261

262262
config ARCH_SUPPORTS_KEXEC_PURGATORY
263-
def_bool KEXEC_FILE
263+
def_bool y
264264

265265
config ARCH_SUPPORTS_CRASH_DUMP
266266
def_bool y

arch/x86/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,15 +2072,15 @@ config ARCH_SUPPORTS_KEXEC
20722072
def_bool y
20732073

20742074
config ARCH_SUPPORTS_KEXEC_FILE
2075-
def_bool X86_64 && CRYPTO && CRYPTO_SHA256
2075+
def_bool X86_64
20762076

20772077
config ARCH_SELECTS_KEXEC_FILE
20782078
def_bool y
20792079
depends on KEXEC_FILE
20802080
select HAVE_IMA_KEXEC if IMA
20812081

20822082
config ARCH_SUPPORTS_KEXEC_PURGATORY
2083-
def_bool KEXEC_FILE
2083+
def_bool y
20842084

20852085
config ARCH_SUPPORTS_KEXEC_SIG
20862086
def_bool y

kernel/Kconfig.kexec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ config KEXEC
3636
config KEXEC_FILE
3737
bool "Enable kexec file based system call"
3838
depends on ARCH_SUPPORTS_KEXEC_FILE
39+
select CRYPTO
40+
select CRYPTO_SHA256
3941
select KEXEC_CORE
4042
help
4143
This is new version of kexec system call. This system call is

lib/maple_tree.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5501,6 +5501,17 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
55015501

55025502
mas_wr_end_piv(&wr_mas);
55035503
node_size = mas_wr_new_end(&wr_mas);
5504+
5505+
/* Slot store, does not require additional nodes */
5506+
if (node_size == wr_mas.node_end) {
5507+
/* reuse node */
5508+
if (!mt_in_rcu(mas->tree))
5509+
return 0;
5510+
/* shifting boundary */
5511+
if (wr_mas.offset_end - mas->offset == 1)
5512+
return 0;
5513+
}
5514+
55045515
if (node_size >= mt_slots[wr_mas.type]) {
55055516
/* Split, worst case for now. */
55065517
request = 1 + mas_mt_height(mas) * 2;

mm/filemap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,15 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
26072607
goto put_folios;
26082608
end_offset = min_t(loff_t, isize, iocb->ki_pos + iter->count);
26092609

2610+
/*
2611+
* Pairs with a barrier in
2612+
* block_write_end()->mark_buffer_dirty() or other page
2613+
* dirtying routines like iomap_write_end() to ensure
2614+
* changes to page contents are visible before we see
2615+
* increased inode size.
2616+
*/
2617+
smp_rmb();
2618+
26102619
/*
26112620
* Once we start copying data, we don't want to be touching any
26122621
* cachelines that might be contended:

mm/kasan/kasan_test.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,59 +493,71 @@ static void kmalloc_oob_memset_2(struct kunit *test)
493493
{
494494
char *ptr;
495495
size_t size = 128 - KASAN_GRANULE_SIZE;
496+
size_t memset_size = 2;
496497

497498
KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test);
498499

499500
ptr = kmalloc(size, GFP_KERNEL);
500501
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
501502

503+
OPTIMIZER_HIDE_VAR(ptr);
502504
OPTIMIZER_HIDE_VAR(size);
503-
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, 2));
505+
OPTIMIZER_HIDE_VAR(memset_size);
506+
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, memset_size));
504507
kfree(ptr);
505508
}
506509

507510
static void kmalloc_oob_memset_4(struct kunit *test)
508511
{
509512
char *ptr;
510513
size_t size = 128 - KASAN_GRANULE_SIZE;
514+
size_t memset_size = 4;
511515

512516
KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test);
513517

514518
ptr = kmalloc(size, GFP_KERNEL);
515519
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
516520

521+
OPTIMIZER_HIDE_VAR(ptr);
517522
OPTIMIZER_HIDE_VAR(size);
518-
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, 4));
523+
OPTIMIZER_HIDE_VAR(memset_size);
524+
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, memset_size));
519525
kfree(ptr);
520526
}
521527

522528
static void kmalloc_oob_memset_8(struct kunit *test)
523529
{
524530
char *ptr;
525531
size_t size = 128 - KASAN_GRANULE_SIZE;
532+
size_t memset_size = 8;
526533

527534
KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test);
528535

529536
ptr = kmalloc(size, GFP_KERNEL);
530537
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
531538

539+
OPTIMIZER_HIDE_VAR(ptr);
532540
OPTIMIZER_HIDE_VAR(size);
533-
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, 8));
541+
OPTIMIZER_HIDE_VAR(memset_size);
542+
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, memset_size));
534543
kfree(ptr);
535544
}
536545

537546
static void kmalloc_oob_memset_16(struct kunit *test)
538547
{
539548
char *ptr;
540549
size_t size = 128 - KASAN_GRANULE_SIZE;
550+
size_t memset_size = 16;
541551

542552
KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test);
543553

544554
ptr = kmalloc(size, GFP_KERNEL);
545555
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
546556

557+
OPTIMIZER_HIDE_VAR(ptr);
547558
OPTIMIZER_HIDE_VAR(size);
548-
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, 16));
559+
OPTIMIZER_HIDE_VAR(memset_size);
560+
KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, memset_size));
549561
kfree(ptr);
550562
}
551563

mm/memory-failure.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,9 @@ struct task_struct *task_early_kill(struct task_struct *tsk, int force_early)
595595
/*
596596
* Collect processes when the error hit an anonymous page.
597597
*/
598-
static void collect_procs_anon(struct page *page, struct list_head *to_kill,
599-
int force_early)
598+
static void collect_procs_anon(struct folio *folio, struct page *page,
599+
struct list_head *to_kill, int force_early)
600600
{
601-
struct folio *folio = page_folio(page);
602601
struct vm_area_struct *vma;
603602
struct task_struct *tsk;
604603
struct anon_vma *av;
@@ -633,12 +632,12 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
633632
/*
634633
* Collect processes when the error hit a file mapped page.
635634
*/
636-
static void collect_procs_file(struct page *page, struct list_head *to_kill,
637-
int force_early)
635+
static void collect_procs_file(struct folio *folio, struct page *page,
636+
struct list_head *to_kill, int force_early)
638637
{
639638
struct vm_area_struct *vma;
640639
struct task_struct *tsk;
641-
struct address_space *mapping = page->mapping;
640+
struct address_space *mapping = folio->mapping;
642641
pgoff_t pgoff;
643642

644643
i_mmap_lock_read(mapping);
@@ -704,17 +703,17 @@ static void collect_procs_fsdax(struct page *page,
704703
/*
705704
* Collect the processes who have the corrupted page mapped to kill.
706705
*/
707-
static void collect_procs(struct page *page, struct list_head *tokill,
708-
int force_early)
706+
static void collect_procs(struct folio *folio, struct page *page,
707+
struct list_head *tokill, int force_early)
709708
{
710-
if (!page->mapping)
709+
if (!folio->mapping)
711710
return;
712711
if (unlikely(PageKsm(page)))
713712
collect_procs_ksm(page, tokill, force_early);
714713
else if (PageAnon(page))
715-
collect_procs_anon(page, tokill, force_early);
714+
collect_procs_anon(folio, page, tokill, force_early);
716715
else
717-
collect_procs_file(page, tokill, force_early);
716+
collect_procs_file(folio, page, tokill, force_early);
718717
}
719718

720719
struct hwpoison_walk {
@@ -1571,7 +1570,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
15711570
* This check implies we don't kill processes if their pages
15721571
* are in the swap cache early. Those are always late kills.
15731572
*/
1574-
if (!page_mapped(hpage))
1573+
if (!page_mapped(p))
15751574
return true;
15761575

15771576
if (PageSwapCache(p)) {
@@ -1602,7 +1601,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
16021601
* mapped in dirty form. This has to be done before try_to_unmap,
16031602
* because ttu takes the rmap data structures down.
16041603
*/
1605-
collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);
1604+
collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED);
16061605

16071606
if (PageHuge(hpage) && !PageAnon(hpage)) {
16081607
/*
@@ -1622,10 +1621,10 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
16221621
try_to_unmap(folio, ttu);
16231622
}
16241623

1625-
unmap_success = !page_mapped(hpage);
1624+
unmap_success = !page_mapped(p);
16261625
if (!unmap_success)
16271626
pr_err("%#lx: failed to unmap page (mapcount=%d)\n",
1628-
pfn, page_mapcount(hpage));
1627+
pfn, page_mapcount(p));
16291628

16301629
/*
16311630
* try_to_unmap() might put mlocked page in lru cache, so call
@@ -1705,7 +1704,7 @@ static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn,
17051704
* mapping being torn down is communicated in siginfo, see
17061705
* kill_proc()
17071706
*/
1708-
loff_t start = (index << PAGE_SHIFT) & ~(size - 1);
1707+
loff_t start = ((loff_t)index << PAGE_SHIFT) & ~(size - 1);
17091708

17101709
unmap_mapping_range(mapping, start, size, 0);
17111710
}
@@ -1772,7 +1771,7 @@ static int mf_generic_kill_procs(unsigned long long pfn, int flags,
17721771
* SIGBUS (i.e. MF_MUST_KILL)
17731772
*/
17741773
flags |= MF_ACTION_REQUIRED | MF_MUST_KILL;
1775-
collect_procs(&folio->page, &to_kill, true);
1774+
collect_procs(folio, &folio->page, &to_kill, true);
17761775

17771776
unmap_and_kill(&to_kill, pfn, folio->mapping, folio->index, flags);
17781777
unlock:

0 commit comments

Comments
 (0)