Skip to content

Commit e1b6ecb

Browse files
committed
ci/diffs: add patches with vmalloc fixes
Recent mm patch [1] causes a regression in BPF verifier which leads to selftest failures. In particular verifier_loops1 test gets killed by the test_progs watchdog [2], although normally it passes in a few seconds. This has been reported on the mailing list [3], and the fixes are in flight [4]. Add them as CI-specific patches for now. [1] https://lore.kernel.org/all/20250424023119.work.333-kees@kernel.org [2] https://github.com/kernel-patches/bpf/actions/runs/15144596086/job/42577510982 [3] https://lore.kernel.org/lkml/20250515-bpf-verifier-slowdown-vwo2meju4cgp2su5ckj@6gi6ssxbnfqg/ [4] https://lore.kernel.org/all/20250515214020.work.519-kees@kernel.org/ Signed-off-by: Ihor Solodrai <isolodrai@meta.com>
1 parent fd7d12f commit e1b6ecb

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 0bb67681b72aa792751141567263cfa2d27a12ce Mon Sep 17 00:00:00 2001
2+
From: Kees Cook <kees@kernel.org>
3+
Date: Thu, 15 May 2025 14:42:15 -0700
4+
Subject: [PATCH 1/2] mm: vmalloc: Actually use the in-place vrealloc region
5+
6+
The refactoring to not build a new vmalloc region only actually worked
7+
when shrinking. Actually return the resized area when it grows. Ugh.
8+
9+
Reported-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
10+
Closes: https://lore.kernel.org/all/20250515-bpf-verifier-slowdown-vwo2meju4cgp2su5ckj@6gi6ssxbnfqg
11+
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
12+
Tested-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
13+
Fixes: a0309faf1cb0 ("mm: vmalloc: support more granular vrealloc() sizing")
14+
Signed-off-by: Kees Cook <kees@kernel.org>
15+
---
16+
mm/vmalloc.c | 1 +
17+
1 file changed, 1 insertion(+)
18+
19+
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
20+
index 2d7511654831..74bd00fd734d 100644
21+
--- a/mm/vmalloc.c
22+
+++ b/mm/vmalloc.c
23+
@@ -4111,6 +4111,7 @@ void *vrealloc_noprof(const void *p, size_t size, gfp_t flags)
24+
if (want_init_on_alloc(flags))
25+
memset((void *)p + old_size, 0, size - old_size);
26+
vm->requested_size = size;
27+
+ return (void *)p;
28+
}
29+
30+
/* TODO: Grow the vm_area, i.e. allocate and map additional pages. */
31+
--
32+
2.47.1
33+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
From a71cfa01cb28c84db871af20ae18a58f7cb41382 Mon Sep 17 00:00:00 2001
2+
From: Kees Cook <kees@kernel.org>
3+
Date: Thu, 15 May 2025 14:42:16 -0700
4+
Subject: [PATCH 2/2] mm: vmalloc: Only zero-init on vrealloc shrink
5+
6+
The common case is to grow reallocations, and since init_on_alloc will
7+
have already zeroed the whole allocation, we only need to zero when
8+
shrinking the allocation.
9+
10+
Fixes: a0309faf1cb0 ("mm: vmalloc: support more granular vrealloc() sizing")
11+
Tested-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
12+
Signed-off-by: Kees Cook <kees@kernel.org>
13+
---
14+
mm/vmalloc.c | 12 +++++++-----
15+
1 file changed, 7 insertions(+), 5 deletions(-)
16+
17+
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
18+
index 74bd00fd734d..00cf1b575c89 100644
19+
--- a/mm/vmalloc.c
20+
+++ b/mm/vmalloc.c
21+
@@ -4093,8 +4093,8 @@ void *vrealloc_noprof(const void *p, size_t size, gfp_t flags)
22+
* would be a good heuristic for when to shrink the vm_area?
23+
*/
24+
if (size <= old_size) {
25+
- /* Zero out "freed" memory. */
26+
- if (want_init_on_free())
27+
+ /* Zero out "freed" memory, potentially for future realloc. */
28+
+ if (want_init_on_free() || want_init_on_alloc(flags))
29+
memset((void *)p + size, 0, old_size - size);
30+
vm->requested_size = size;
31+
kasan_poison_vmalloc(p + size, old_size - size);
32+
@@ -4107,9 +4107,11 @@ void *vrealloc_noprof(const void *p, size_t size, gfp_t flags)
33+
if (size <= alloced_size) {
34+
kasan_unpoison_vmalloc(p + old_size, size - old_size,
35+
KASAN_VMALLOC_PROT_NORMAL);
36+
- /* Zero out "alloced" memory. */
37+
- if (want_init_on_alloc(flags))
38+
- memset((void *)p + old_size, 0, size - old_size);
39+
+ /*
40+
+ * No need to zero memory here, as unused memory will have
41+
+ * already been zeroed at initial allocation time or during
42+
+ * realloc shrink time.
43+
+ */
44+
vm->requested_size = size;
45+
return (void *)p;
46+
}
47+
--
48+
2.47.1
49+

0 commit comments

Comments
 (0)