incoming
Subsystems (8)
Andrew Morton
maintainer9 patches, based on d00c50b35101b862c3db270ffeba53a63a1063d9.
Subsystems affected by this patch series:
mm/migration
mm/highmem
lz4
mm/sparsemem
mm/mremap
mm/mempolicy
mailmap
mm/memcg
MAINTAINERS
Subsystem: mm/migration
Zi Yan <[email protected]>:
mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.
Subsystem: mm/highmem
Max Filippov <[email protected]>:
highmem: fix checks in __kmap_local_sched_{in,out}
Subsystem: lz4
Guo Xuenan <[email protected]>:
lz4: fix LZ4_decompress_safe_partial read out of bound
Subsystem: mm/sparsemem
Waiman Long <[email protected]>:
mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
Subsystem: mm/mremap
Paolo Bonzini <[email protected]>:
mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
Subsystem: mm/mempolicy
Miaohe Lin <[email protected]>:
mm/mempolicy: fix mpol_new leak in shared_policy_replace
Subsystem: mailmap
Vasily Averin <[email protected]>:
mailmap: update Vasily Averin's email address
Subsystem: mm/memcg
Andrew Morton <[email protected]>:
mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()"
Subsystem: MAINTAINERS
Tom Rix <[email protected]>:
MAINTAINERS: add Tom as clang reviewer
.mailmap | 4 ++++ MAINTAINERS | 1 + include/linux/mmzone.h | 11 +++++++---- lib/lz4/lz4_decompress.c | 8 ++++++-- mm/highmem.c | 4 ++-- mm/list_lru.c | 6 ------ mm/mempolicy.c | 3 ++- mm/migrate.c | 2 +- mm/mremap.c | 3 +++ 9 files changed, 26 insertions(+), 16 deletions(-)
Andrew Morton
maintainerPATCH 1/9 mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.
From: Zi Yan <[email protected]>
Subject: mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.
Fix a VM_BUG_ON_FOLIO(folio_nr_pages(old) != nr_pages) crash.
With folios support, it is possible to have other than HPAGE_PMD_ORDER THPs, in the form of folios, in the system. Use thp_order() to correctly determine the source page order during migration.
---
mm/mempolicy.c | 2 +- mm/migrate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
mm/mempolicy.c renamed from mm/mempolicy.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +1 -1
@@ -1209,7 +1209,7 @@ static struct page *new_page(struct pagestruct page *thp; thp =alloc_hugepage_vma (GFP_TRANSHUGE , vma, address, -HPAGE_PMD_ORDER ); +thp_order (page));if (!thp)return NULL ;prep_transhuge_page (thp);
mm/migrate.c renamed from mm/migrate.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +1 -1
@@ -1547,7 +1547,7 @@ struct page *alloc_migration_target(stru*/ gfp_mask &= ~__GFP_RECLAIM; gfp_mask |=GFP_TRANSHUGE ; - order =HPAGE_PMD_ORDER ; + order =thp_order (page); } zidx =zone_idx (page_zone (page));if (is_highmem_idx (zidx) || zidx ==ZONE_MOVABLE )
_
Re: [patch 1/9] mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.
Quoted 8 lines · Andrew Morton
From: Zi Yan <[email protected]>
Subject: mm: migrate: usethp_orderinstead ofHPAGE_PMD_ORDERfor new page allocation.Fix a
VM_BUG_ON_FOLIO(folio_nr_pages(old) != nr_pages)crash.With folios support, it is possible to have other than
HPAGE_PMD_ORDERTHPs, in the form of folios, in the system. Usethp_order()to correctly determine the source page order during migration.
This one's now obsolete after the folio pull request Linus merged earlier today.
Quoted 38 lines
Fixes d68eccad3706 ("mm/filemap: Allow large folios to be added to the page cache")Reported-by Naoya Horiguchi <[email protected]>Signed-off-by Zi Yan <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Michal Hocko <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
mm/mempolicy.c | 2 +- mm/migrate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)mm/mempolicy.c renamed from mm/mempolicy.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +1
-1@@ -1209,7 +1209,7 @@ static struct page *new_page(struct pagestruct page *thp; thp =alloc_hugepage_vma (GFP_TRANSHUGE , vma, address, -HPAGE_PMD_ORDER ); +thp_order (page));if (!thp)return NULL ;prep_transhuge_page (thp);mm/migrate.c renamed from mm/migrate.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +1
-1@@ -1547,7 +1547,7 @@ struct page *alloc_migration_target(stru*/ gfp_mask &= ~__GFP_RECLAIM; gfp_mask |=GFP_TRANSHUGE ; - order =HPAGE_PMD_ORDER ; + order =thp_order (page); } zidx =zone_idx (page_zone (page));if (is_highmem_idx (zidx) || zidx ==ZONE_MOVABLE )_
Andrew Morton
maintainerPATCH 2/9 highmem: fix checks in __kmap_local_sched_{in,out}
In reply to Andrew MortonFrom: Max Filippov <[email protected]>
Subject: highmem: fix checks in __kmap_local_sched_{in,out}
When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check that even slots in the tsk->kmap_ctrl.pteval are unmapped. The slots are initialized with 0 value, but the check is done with pte_none. 0 pte however does not necessarily mean that pte_none will return true. e.g. on xtensa it returns false, resulting in the following runtime warnings:
WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0x108 CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_out+0x51/0x108 __schedule+0x71a/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0xe0 CPU: 0 PID: 101 Comm: touch Tainted: G W 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_in+0x50/0xe0 finish_task_switch$isra$0+0x1ce/0x2f8 __schedule+0x86e/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f
Fix it by replacing !pte_none(pteval) with pte_val(pteval) != 0.
---
mm/highmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/highmem.c renamed from mm/highmem.c~highmem-fix-checks-in-__kmap_local_sched_inout +2 -2
@@ -624,7 +624,7 @@ void __kmap_local_sched_out(void)/* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED (CONFIG_DEBUG_KMAP_LOCAL ) && !(i &0x01 )) { -WARN_ON_ONCE (!pte_none (pteval)); +WARN_ON_ONCE (pte_val (pteval) !=0 );continue ; }if (WARN_ON_ONCE (pte_none (pteval)))
@@ -661,7 +661,7 @@ void __kmap_local_sched_in(void)/* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED (CONFIG_DEBUG_KMAP_LOCAL ) && !(i &0x01 )) { -WARN_ON_ONCE (!pte_none (pteval)); +WARN_ON_ONCE (pte_val (pteval) !=0 );continue ; }if (WARN_ON_ONCE (pte_none (pteval)))
_
Andrew Morton
maintainerPATCH 3/9 lz4: fix LZ4_decompress_safe_partial read out of bound
In reply to Andrew MortonFrom: Guo Xuenan <[email protected]>
Subject: lz4: fix LZ4_decompress_safe_partial read out of bound
When partialDecoding, it is EOF if we've either filled the output buffer or can't proceed with reading an offset for following match.
In some extreme corner cases when compressed data is suitably corrupted, UAF will occur. As reported by KASAN [1], LZ4_decompress_safe_partial may lead to read out of bound problem during decoding. lz4 upstream has fixed it [2] and this issue has been disscussed here [3] before.
current decompression routine was ported from lz4 v1.8.3, bumping lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd better fix it first.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad244ad#
[3] https://lore.kernel.org/all/[email protected]/
---
lib/lz4/lz4_decompress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/lz4/lz4_decompress.c renamed from lib/lz4/lz4_decompress.c~lz4-fix-lz4_decompress_safe_partial-read-out-of-bound +6 -2
@@ -271,8 +271,12 @@ static FORCE_INLINE int LZ4_decompress_g ip += length; op += length; -/* Necessarily EOF, due to parsing restrictions */ -if (!partialDecoding || (cpy == oend)) +/* Necessarily EOF when !partialDecoding. +* When partialDecoding, it is EOF if we've either +* filled the output buffer or +* can't proceed with reading an offset for following match. +*/ +if (!partialDecoding || (cpy == oend) || (ip >= (iend -2 )))break ; }else {/* may overwrite up to WILDCOPYLENGTH beyond cpy */
_
Andrew Morton
maintainerPATCH 4/9 mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
In reply to Andrew MortonFrom: Waiman Long <[email protected]>
Subject: mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
The gcc 12 compiler reports a "'mem_section' will never be NULL" warning on the following code:
static inline struct mem_section *__nr_to_section(unsigned long nr)
{
#ifdef CONFIG_SPARSEMEM_EXTREME
if (!mem_section)
return NULL;
#endif
if (!mem_section[SECTION_NR_TO_ROOT(nr)])
return NULL;
:It happens with CONFIG_SPARSEMEM_EXTREME off. The mem_section definition is
#ifdef CONFIG_SPARSEMEM_EXTREME
extern struct mem_section **mem_section;
#else
extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
#endifIn the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static 2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]" doesn't make sense.
Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]" check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an explicit NR_SECTION_ROOTS check to make sure that there is no out-of-bound array access.
---
include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-sparsemem-fix-mem_section-will-never-be-null-gcc-12-warning +7 -4
@@ -1397,13 +1397,16 @@ static inline unsigned long *section_to_static inline struct mem_section *__nr_to_section (unsigned long nr) { +unsigned long root =SECTION_NR_TO_ROOT (nr); + +if (unlikely (root >=NR_SECTION_ROOTS )) +return NULL ; +#ifdef CONFIG_SPARSEMEM_EXTREME -if (!mem_section) +if (!mem_section || !mem_section[root])return NULL ;#endif -if (!mem_section[SECTION_NR_TO_ROOT (nr)]) -return NULL ; -return &mem_section[SECTION_NR_TO_ROOT (nr)][nr &SECTION_ROOT_MASK ]; +return &mem_section[root][nr &SECTION_ROOT_MASK ]; }extern size_t mem_section_usage_size (void );
_
Re: [patch 4/9] mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
Quoted 3 lines · Andrew Morton
From: Waiman Long <[email protected]>
Subject: mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
...
Quoted 8 lines
Fixes 3e347261a80b ("sparsemem extreme implementation")Signed-off-by Waiman Long <[email protected]>Reported-by Justin Forbes <[email protected]>Cc "Kirill A . Shutemov" <[email protected]>Cc Ingo Molnar <[email protected]>Cc Rafael Aquini <[email protected]>Signed-off-by Andrew Morton <[email protected]>
Signature · 2 lines
Oscar Salvador SUSE Labs
Andrew Morton
maintainerPATCH 5/9 mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
In reply to Andrew MortonFrom: Paolo Bonzini <[email protected]>
Subject: mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range.
This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue.
---
mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+)
mm/mremap.c renamed from mm/mremap.c~mm-avoid-pointless-invalidate_range_start-end-on-mremapold_size=0 +3 -0
@@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vmpmd_t *old_pmd, *new_pmd;pud_t *old_pud, *new_pud; +if (!len) +return 0 ; + old_end = old_addr + len;flush_cache_range (vma, old_addr, old_end);
_
Andrew Morton
maintainerPATCH 6/9 mm/mempolicy: fix mpol_new leak in shared_policy_replace
In reply to Andrew MortonFrom: Miaohe Lin <[email protected]>
Subject: mm/mempolicy: fix mpol_new leak in shared_policy_replace
If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation.
This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time:
shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT);
shm = shmat(shmid, 0, 0);
loop many times {
mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0);
mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask,
maxnode, 0);
}---
mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+)
mm/mempolicy.c renamed from mm/mempolicy.c~mm-mempolicy-fix-mpol_new-leak-in-shared_policy_replace +1 -0
@@ -2733,6 +2733,7 @@ alloc_new: mpol_new =kmem_cache_alloc (policy_cache,GFP_KERNEL );if (!mpol_new) goto err_out; +atomic_set (&mpol_new->refcnt,1 ); goto restart; }
_
Andrew Morton
maintainerPATCH 7/9 mailmap: update Vasily Averin's email address
In reply to Andrew MortonFrom: Vasily Averin <[email protected]>
Subject: mailmap: update Vasily Averin's email address
I'm moving to a @linux.dev account. Map my old addresses.
---
.mailmap | 4 ++++ 1 file changed, 4 insertions(+)
.mailmap renamed from .mailmap~mailmap-update-vasily-averins-email-address +4 -0
@@ -391,6 +391,10 @@ Uwe Kleine-König <[email protected]> Uwe Kleine-König <[email protected]> Uwe Kleine-König <[email protected]> Valdis Kletnieks <[email protected]> +Vasily Averin <[email protected]> <[email protected]> +Vasily Averin <[email protected]> <[email protected]> +Vasily Averin <[email protected]> <[email protected]> +Vasily Averin <[email protected]> <[email protected]> Vinod Koul <[email protected]> <[email protected]> Vinod Koul <[email protected]> <[email protected]> Vinod Koul <[email protected]> <[email protected]>
_
Andrew Morton
maintainerPATCH 8/9 mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()"
In reply to Andrew MortonFrom: Andrew Morton <[email protected]>
Subject: mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()"
405cc51fc1049c73 ("mm/list_lru: optimize memcg_reparent_list_lru_node()") has subtle races which are proving ugly to fix. Revert the original optimization. If quantitative testing indicates that we have a significant problem here then other implementations can be looked at.
---
mm/list_lru.c | 6 ------ 1 file changed, 6 deletions(-)
mm/list_lru.c renamed from mm/list_lru.c~mm-list_lruc-revert-mm-list_lru-optimize-memcg_reparent_list_lru_node +0 -6
@@ -395,12 +395,6 @@ static void memcg_reparent_list_lru_nodestruct list_lru_one *src, *dst;/* -* If there is no lru entry in this nlru, we can skip it immediately. -*/ -if (!READ_ONCE (nlru->nr_items)) -return ; - -/* * Since list_lru_{add,del} may be called under an IRQ-safe lock, * we have to use IRQ-safe primitives here to avoid deadlock. */
_
Andrew Morton
maintainerPATCH 9/9 MAINTAINERS: add Tom as clang reviewer
In reply to Andrew MortonFrom: Tom Rix <[email protected]>
Subject: MAINTAINERS: add Tom as clang reviewer
I have been helping with build breaks and other clang things and would like to help with the reviews.
---
MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS renamed from MAINTAINERS~maintainers-add-self-as-clang-reviewer +1 -0
@@ -4791,6 +4791,7 @@ F: .clang-format CLANG/LLVM BUILD SUPPORT M: Nathan Chancellor <[email protected]> M: Nick Desaulniers <[email protected]> +R: Tom Rix <[email protected]> L: [email protected] S: Supported W: https://clangbuiltlinux.github.io/
_