incoming
Subsystems (6)
Andrew Morton
maintainer12 patches, based on c47658311d60be064b839f329c0e4d34f5f0735b.
Subsystems affected by this patch series:
MAINTAINERS
mm/hugetlb
mm/kasan
mm/hugetlbfs
mm/pagemap
mm/selftests
mm/memcg
m/slab
mailmap
memfd
Subsystem: MAINTAINERS
Luis Chamberlain <[email protected]>:
MAINTAINERS: add sysctl-next git tree
Subsystem: mm/hugetlb
"Aneesh Kumar K.V" <[email protected]>:
mm/hugetlb: fix kernel crash with hugetlb mremap
Subsystem: mm/kasan
Andrey Konovalov <[email protected]>:
kasan: test: prevent cache merging in kmem_cache_double_destroy
Subsystem: mm/hugetlbfs
Liu Yuntao <[email protected]>:
hugetlbfs: fix a truncation issue in hugepages parameter
Subsystem: mm/pagemap
Suren Baghdasaryan <[email protected]>:
mm: fix use-after-free bug when mm->mmap is reused after being freed
Subsystem: mm/selftests
"Aneesh Kumar K.V" <[email protected]>:
selftest/vm: fix map_fixed_noreplace test failure
Subsystem: mm/memcg
Roman Gushchin <[email protected]>:
MAINTAINERS: add Roman as a memcg co-maintainer
Vladimir Davydov <[email protected]>:
MAINTAINERS: remove Vladimir from memcg maintainers
Shakeel Butt <[email protected]>:
MAINTAINERS: add Shakeel as a memcg co-maintainer
Subsystem: m/slab
Vlastimil Babka <[email protected]>:
MAINTAINERS, SLAB: add Roman as reviewer, git tree
Subsystem: mailmap
Roman Gushchin <[email protected]>:
mailmap: update Roman Gushchin's email
Subsystem: memfd
Mike Kravetz <[email protected]>:
selftests/memfd: clean up mapping in mfd_fail_write
.mailmap | 3 + MAINTAINERS | 6 ++ lib/test_kasan.c | 5 +- mm/hugetlb.c | 11 ++--- mm/mmap.c | 1 tools/testing/selftests/memfd/memfd_test.c | 1 tools/testing/selftests/vm/map_fixed_noreplace.c | 49 +++++++++++++++++------ 7 files changed, 56 insertions(+), 20 deletions(-)
Andrew Morton
maintainerPATCH 1/12 MAINTAINERS: add sysctl-next git tree
From: Luis Chamberlain <[email protected]>
Subject: MAINTAINERS: add sysctl-next git tree
Add a git tree for sysctls as there's been quite a bit of work lately to remove all the syctls out of kernel/sysctl.c and move to their respective places, so coordination has been needed to avoid conflicts. This tree will also help soak these changes on linux-next prior to getting to Linus.
---
MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS renamed from MAINTAINERS~maintainers-add-sysctl-next-git-tree +1 -0
@@ -15567,6 +15567,7 @@ M: Iurii Zaikin <[email protected]> L: [email protected] L: [email protected] S: Maintained +T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git sysctl-next F: fs/proc/proc_sysctl.c F: include/linux/sysctl.h F: kernel/sysctl-test.c
_
Andrew Morton
maintainerPATCH 2/12 mm/hugetlb: fix kernel crash with hugetlb mremap
In reply to Andrew MortonFrom: "Aneesh Kumar K.V" <[email protected]>
Subject: mm/hugetlb: fix kernel crash with hugetlb mremap
This fixes the below crash:
kernel BUG at include/linux/mm.h:2373!
cpu 0x5d: Vector: 700 (Program Check) at [c00000003c6e76e0]
pc: c000000000581a54: pmd_to_page+0x54/0x80
lr: c00000000058d184: move_hugetlb_page_tables+0x4e4/0x5b0
sp: c00000003c6e7980 msr: 9000000000029033
current = 0xc00000003bd8d980
paca = 0xc000200fff610100 irqmask: 0x03 irq_happened: 0x01
pid = 9349, comm = hugepage-mremap
kernel BUG at include/linux/mm.h:2373!
[link register ] c00000000058d184 move_hugetlb_page_tables+0x4e4/0x5b0
[c00000003c6e7980] c00000000058cecc move_hugetlb_page_tables+0x22c/0x5b0 (unreliable) [c00000003c6e7a90] c00000000053b78c move_page_tables+0xdbc/0x1010 [c00000003c6e7bd0] c00000000053bc34 move_vma+0x254/0x5f0 [c00000003c6e7c90] c00000000053c790 sys_mremap+0x7c0/0x900 [c00000003c6e7db0] c00000000002c450 system_call_exception+0x160/0x2c0
the kernel can't use huge_pte_offset before it set the pte entry because a page table lookup check for huge PTE bit in the page table to differentiate between a huge pte entry and a pointer to pte page. A huge_pte_alloc won't mark the page table entry huge and hence kernel should not use huge_pte_offset after a huge_pte_alloc.
---
mm/hugetlb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-fix-kernel-crash-with-hugetlb-mremap +3 -4
@@ -4851,14 +4851,13 @@ again: }static void move_huge_pte (struct vm_area_struct *vma,unsigned long old_addr, -unsigned long new_addr,pte_t *src_pte) +unsigned long new_addr,pte_t *src_pte,pte_t *dst_pte) {struct hstate *h =hstate_vma (vma);struct mm_struct *mm = vma->vm_mm; -pte_t *dst_pte, pte;spinlock_t *src_ptl, *dst_ptl; +pte_t pte; - dst_pte =huge_pte_offset (mm, new_addr,huge_page_size (h)); dst_ptl =huge_pte_lock (h, mm, dst_pte); src_ptl =huge_pte_lockptr (h, mm, src_pte);
@@ -4917,7 +4916,7 @@ int move_hugetlb_page_tables(struct vm_aif (!dst_pte)break ; -move_huge_pte (vma, old_addr, new_addr, src_pte); +move_huge_pte (vma, old_addr, new_addr, src_pte, dst_pte); }flush_tlb_range (vma, old_end - len, old_end);mmu_notifier_invalidate_range_end (&range);
_
Andrew Morton
maintainerPATCH 3/12 kasan: test: prevent cache merging in kmem_cache_double_destroy
In reply to Andrew MortonFrom: Andrey Konovalov <[email protected]>
Subject: kasan: test: prevent cache merging in kmem_cache_double_destroy
With HW_TAGS KASAN and kasan.stacktrace=off, the cache created in the kmem_cache_double_destroy() test might get merged with an existing one. Thus, the first kmem_cache_destroy() call won't actually destroy it but will only decrease the refcount. This causes the test to fail.
Provide an empty constructor for the created cache to prevent the cache from getting merged.
---
lib/test_kasan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/test_kasan.c renamed from lib/test_kasan.c~kasan-test-prevent-cache-merging-in-kmem_cache_double_destroy +4 -1
@@ -869,11 +869,14 @@ static void kmem_cache_invalid_free(strukmem_cache_destroy (cache); } +static void empty_cache_ctor (void *object) { } +static void kmem_cache_double_destroy (struct kunit *test) {struct kmem_cache *cache; - cache =kmem_cache_create ("test_cache" ,200 ,0 ,0 ,NULL ); +/* Provide a constructor to prevent cache merging. */ + cache =kmem_cache_create ("test_cache" ,200 ,0 ,0 , empty_cache_ctor);KUNIT_ASSERT_NOT_ERR_OR_NULL (test, cache);kmem_cache_destroy (cache);KUNIT_EXPECT_KASAN_FAIL (test,kmem_cache_destroy (cache));
_
Andrew Morton
maintainerPATCH 4/12 hugetlbfs: fix a truncation issue in hugepages parameter
In reply to Andrew MortonFrom: Liu Yuntao <[email protected]>
Subject: hugetlbfs: fix a truncation issue in hugepages parameter
When we specify a large number for node in hugepages parameter, it may be parsed to another number due to truncation in this statement:
node = tmp;
For example, add following parameter in command line:
hugepagesz=1G hugepages=4294967297:5
and kernel will allocate 5 hugepages for node 1 instead of ignoring it.
I move the validation check earlier to fix this issue, and slightly simplifies the condition here.
---
mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/hugetlb.c renamed from mm/hugetlb.c~hugetlbfs-fix-a-truncation-issue-in-hugepages-parameter +2 -2
@@ -4159,10 +4159,10 @@ static int __init hugepages_setup(char *pr_warn ("HugeTLB: architecture can't support node specific alloc, ignoring!\n" );return 0 ; } +if (tmp >= nr_online_nodes) + goto invalid; node = tmp; p += count +1 ; -if (node <0 || node >= nr_online_nodes) - goto invalid;/* Parse hugepages */ if (sscanf (p,"%lu%n" , &tmp, &count) !=1 ) goto invalid;
_
Andrew Morton
maintainerPATCH 5/12 mm: fix use-after-free bug when mm->mmap is reused after being freed
In reply to Andrew MortonFrom: Suren Baghdasaryan <[email protected]>
Subject: mm: fix use-after-free bug when mm->mmap is reused after being freed
oom reaping (__oom_reap_task_mm) relies on a 2 way synchronization with exit_mmap. First it relies on the mmap_lock to exclude from unlock path[1], page tables tear down (free_pgtables) and vma destruction. This alone is not sufficient because mm->mmap is never reset. For historical reasons[2] the lock is taken there is also MMF_OOM_SKIP set for oom victims before.
The oom reaper only ever looks at oom victims so the whole scheme works properly but process_mrelease can opearate on any task (with fatal signals pending) which doesn't really imply oom victims. That means that the MMF_OOM_SKIP part of the synchronization doesn't work and it can see a task after the whole address space has been demolished and traverse an already released mm->mmap list. This leads to use after free as properly caught up by KASAN report.
Fix the issue by reseting mm->mmap so that MMF_OOM_SKIP synchronization is not needed anymore. The MMF_OOM_SKIP is not removed from exit_mmap yet but it acts mostly as an optimization now.
[1] 27ae357fa82b ("mm, oom: fix concurrent munlock and oom reaper unmap, v3")
[2] 212925802454 ("mm: oom: let oom_reap_task and exit_mmap run concurrently")
---
mm/mmap.c | 1 + 1 file changed, 1 insertion(+)
mm/mmap.c renamed from mm/mmap.c~mm-fix-use-after-free-bug-when-mm-mmap-is-reused-after-being-freed +1 -0
@@ -3186,6 +3186,7 @@ void exit_mmap(struct mm_struct *mm) vma =remove_vma (vma);cond_resched (); } + mm->mmap =NULL ;mmap_write_unlock (mm);vm_unacct_memory (nr_accounted); }
_
Andrew Morton
maintainerPATCH 6/12 selftest/vm: fix map_fixed_noreplace test failure
In reply to Andrew MortonFrom: "Aneesh Kumar K.V" <[email protected]>
Subject: selftest/vm: fix map_fixed_noreplace test failure
On the latest RHEL the test fails due to executable mapped at 256MB address
# ./map_fixed_noreplace mmap() @ 0x10000000-0x10050000 p=0xffffffffffffffff result=File exists 10000000-10010000 r-xp 00000000 fd:04 34905657 /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace 10010000-10020000 r--p 00000000 fd:04 34905657 /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace 10020000-10030000 rw-p 00010000 fd:04 34905657 /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace 10029b90000-10029bc0000 rw-p 00000000 00:00 0 [heap] 7fffbb510000-7fffbb750000 r-xp 00000000 fd:04 24534 /usr/lib64/libc.so.6 7fffbb750000-7fffbb760000 r--p 00230000 fd:04 24534 /usr/lib64/libc.so.6 7fffbb760000-7fffbb770000 rw-p 00240000 fd:04 24534 /usr/lib64/libc.so.6 7fffbb780000-7fffbb7a0000 r--p 00000000 00:00 0 [vvar] 7fffbb7a0000-7fffbb7b0000 r-xp 00000000 00:00 0 [vdso] 7fffbb7b0000-7fffbb800000 r-xp 00000000 fd:04 24514 /usr/lib64/ld64.so.2 7fffbb800000-7fffbb810000 r--p 00040000 fd:04 24514 /usr/lib64/ld64.so.2 7fffbb810000-7fffbb820000 rw-p 00050000 fd:04 24514 /usr/lib64/ld64.so.2 7fffd93f0000-7fffd9420000 rw-p 00000000 00:00 0 [stack] Error: couldn't map the space we need for the test
Fix this by finding a free address using mmap instead of hardcoding BASE_ADDRESS.
---
tools/testing/selftests/vm/map_fixed_noreplace.c | 49 +++++++++---- 1 file changed, 37 insertions(+), 12 deletions(-)
tools/testing/selftests/vm/map_fixed_noreplace.c renamed from tools/testing/selftests/vm/map_fixed_noreplace.c~selftest-vm-fix-map_fixed_noreplace-test-failure +37 -12
@@ -17,9 +17,6 @@#define MAP_FIXED_NOREPLACE 0x100000#endif -#define BASE_ADDRESS (256ul * 1024 * 1024) - -static void dump_maps (void ) {char cmd[32 ];
@@ -28,18 +25,46 @@ static void dump_maps(void)system (cmd); } +static unsigned long find_base_addr (unsigned long size) +{ +void *addr; +unsigned long flags; + + flags =MAP_PRIVATE |MAP_ANONYMOUS ; + addr =mmap (NULL , size,PROT_NONE , flags,-1 ,0 ); +if (addr ==MAP_FAILED ) { +printf ("Error: couldn't map the space we need for the test\n" ); +return 0 ; + } + +if (munmap (addr, size) !=0 ) { +printf ("Error: couldn't map the space we need for the test\n" ); +return 0 ; + } +return (unsigned long )addr; +} +int main (void ) { +unsigned long base_addr;unsigned long flags, addr, size, page_size;char *p; page_size =sysconf (_SC_PAGE_SIZE); +//let's find a base addr that is free before we start the tests + size =5 * page_size; + base_addr =find_base_addr (size); +if (!base_addr) { +printf ("Error: couldn't map the space we need for the test\n" ); +return 1 ; + } + flags =MAP_PRIVATE |MAP_ANONYMOUS |MAP_FIXED_NOREPLACE ;// Check we can map all the areas we need below errno =0 ; - addr =BASE_ADDRESS ; + addr = base_addr; size =5 * page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );
@@ -60,7 +85,7 @@ int main(void)printf ("unmap() successful\n" ); errno =0 ; - addr =BASE_ADDRESS + page_size; + addr = base_addr + page_size; size =3 * page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -80,7 +105,7 @@ int main(void)* +4 | free | new */ errno =0 ; - addr =BASE_ADDRESS ; + addr = base_addr; size =5 * page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -101,7 +126,7 @@ int main(void)* +4 | free | */ errno =0 ; - addr =BASE_ADDRESS + (2 * page_size); + addr = base_addr + (2 * page_size); size = page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -121,7 +146,7 @@ int main(void)* +4 | free | new */ errno =0 ; - addr =BASE_ADDRESS + (3 * page_size); + addr = base_addr + (3 * page_size); size =2 * page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -141,7 +166,7 @@ int main(void)* +4 | free | */ errno =0 ; - addr =BASE_ADDRESS ; + addr = base_addr; size =2 * page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -161,7 +186,7 @@ int main(void)* +4 | free | */ errno =0 ; - addr =BASE_ADDRESS ; + addr = base_addr; size = page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -181,7 +206,7 @@ int main(void)* +4 | free | new */ errno =0 ; - addr =BASE_ADDRESS + (4 * page_size); + addr = base_addr + (4 * page_size); size = page_size; p =mmap ((void *)addr, size,PROT_NONE , flags,-1 ,0 );printf ("mmap() @ 0x%lx-0x%lx p=%p result=%m\n" , addr, addr + size, p);
@@ -192,7 +217,7 @@ int main(void)return 1 ; } - addr =BASE_ADDRESS ; + addr = base_addr; size =5 * page_size;if (munmap ((void *)addr, size) !=0 ) {dump_maps ();
_
Andrew Morton
maintainerPATCH 7/12 MAINTAINERS: add Roman as a memcg co-maintainer
In reply to Andrew MortonFrom: Roman Gushchin <[email protected]>
Subject: MAINTAINERS: add Roman as a memcg co-maintainer
Add myself as a memcg co-maintainer. My primary focus over last few years was the kernel memory accounting stack, but I do work on some other parts of the memory controller as well.
---
MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS renamed from MAINTAINERS~maintainers-add-myself-as-a-memcg-co-maintainer +1 -0
@@ -4914,6 +4914,7 @@ CONTROL GROUP - MEMORY RESOURCE CONTROLL M: Johannes Weiner <[email protected]> M: Michal Hocko <[email protected]> M: Vladimir Davydov <[email protected]> +M: Roman Gushchin <[email protected]> L: [email protected] L: [email protected] S: Maintained
_
Andrew Morton
maintainerPATCH 8/12 MAINTAINERS: remove Vladimir from memcg maintainers
In reply to Andrew MortonFrom: Vladimir Davydov <[email protected]>
Subject: MAINTAINERS: remove Vladimir from memcg maintainers
---
MAINTAINERS | 1 - 1 file changed, 1 deletion(-)
MAINTAINERS renamed from MAINTAINERS~maintainers-remove-myself-from-memcg-maintainers +0 -1
@@ -4913,7 +4913,6 @@ F: kernel/cgroup/cpuset.c CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG) M: Johannes Weiner <[email protected]> M: Michal Hocko <[email protected]> -M: Vladimir Davydov <[email protected]> M: Roman Gushchin <[email protected]> L: [email protected] L: [email protected]
_
Andrew Morton
maintainerPATCH 9/12 MAINTAINERS: add Shakeel as a memcg co-maintainer
In reply to Andrew MortonFrom: Shakeel Butt <[email protected]>
Subject: MAINTAINERS: add Shakeel as a memcg co-maintainer
I have been contributing and reviewing to the memcg codebase for last couple of years. So, making it official.
---
MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS renamed from MAINTAINERS~maintainers-add-myself-as-a-memcg-co-maintainer-as-well +1 -0
@@ -4914,6 +4914,7 @@ CONTROL GROUP - MEMORY RESOURCE CONTROLL M: Johannes Weiner <[email protected]> M: Michal Hocko <[email protected]> M: Roman Gushchin <[email protected]> +M: Shakeel Butt <[email protected]> L: [email protected] L: [email protected] S: Maintained
_
Andrew Morton
maintainerPATCH 10/12 MAINTAINERS, SLAB: add Roman as reviewer, git tree
In reply to Andrew MortonFrom: Vlastimil Babka <[email protected]>
Subject: MAINTAINERS, SLAB: add Roman as reviewer, git tree
The slab code has an overlap with kmem accounting, where Roman has done a lot of work recently and it would be useful to make sure he's CC'd on patches that potentially affect it. Thus add him as a reviewer for the SLAB subsystem.
Also while at it, add the link to slab git tree.
---
MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS renamed from MAINTAINERS~maintainers-slab-add-roman-as-reviewer-git-tree +2 -0
@@ -17762,8 +17762,10 @@ M: David Rientjes <[email protected]> M: Joonsoo Kim <[email protected]> M: Andrew Morton <[email protected]> M: Vlastimil Babka <[email protected]> +R: Roman Gushchin <[email protected]> L: [email protected] S: Maintained +T: git git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git F: include/linux/sl?b*.h F: mm/sl?b*
_
Andrew Morton
maintainerPATCH 11/12 mailmap: update Roman Gushchin's email
In reply to Andrew MortonFrom: Roman Gushchin <[email protected]>
Subject: mailmap: update Roman Gushchin's email
I'm moving to a @linux.dev account. Map my old addresses.
---
.mailmap | 3 +++ 1 file changed, 3 insertions(+)
.mailmap renamed from .mailmap~mailmap-update-roman-gushchins-email +3 -0
@@ -333,6 +333,9 @@ Rémi Denis-Courmont <rdenis@simphalempi Ricardo Ribalda <[email protected]> <[email protected]> Ricardo Ribalda <[email protected]> Ricardo Ribalda Delgado <[email protected]> Ricardo Ribalda <[email protected]> <[email protected]> +Roman Gushchin <[email protected]> <[email protected]> +Roman Gushchin <[email protected]> <[email protected]> +Roman Gushchin <[email protected]> <[email protected]> Ross Zwisler <[email protected]> <[email protected]> Rudolf Marek <[email protected]> Rui Saraiva <[email protected]>
_
Andrew Morton
maintainerPATCH 12/12 selftests/memfd: clean up mapping in mfd_fail_write
In reply to Andrew MortonFrom: Mike Kravetz <[email protected]>
Subject: selftests/memfd: clean up mapping in mfd_fail_write
Running the memfd script ./run_hugetlbfs_test.sh will often end in error as follows:
memfd-hugetlb: CREATE
memfd-hugetlb: BASIC
memfd-hugetlb: SEAL-WRITE
memfd-hugetlb: SEAL-FUTURE-WRITE
memfd-hugetlb: SEAL-SHRINK
fallocate(ALLOC) failed: No space left on device
./run_hugetlbfs_test.sh: line 60: 166855 Aborted (core dumped) ./memfd_test hugetlbfs
opening: ./mnt/memfd
fuse: DONE
If no hugetlb pages have been preallocated, run_hugetlbfs_test.sh will allocate 'just enough' pages to run the test. In the SEAL-FUTURE-WRITE test the mfd_fail_write routine maps the file, but does not unmap. As a result, two hugetlb pages remain reserved for the mapping. When the fallocate call in the SEAL-SHRINK test attempts allocate all hugetlb pages, it is short by the two reserved pages.
Fix by making sure to unmap in mfd_fail_write.
---
tools/testing/selftests/memfd/memfd_test.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/memfd/memfd_test.c renamed from tools/testing/selftests/memfd/memfd_test.c~selftests-memfd-clean-up-mapping-in-mfd_fail_write +1 -0
@@ -455,6 +455,7 @@ static void mfd_fail_write(int fd)printf ("mmap()+mprotect() didn't fail as expected\n" );abort (); } +munmap (p, mfd_def_size); }/* verify PUNCH_HOLE fails */
_