* + mm-kasan-fix-kasan-poisoning-in-vrealloc-fix.patch added to mm-hotfixes-unstable branch
@ 2026-01-19 18:04 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-01-19 18:04 UTC (permalink / raw)
To: mm-commits, vincenzo.frascino, urezki, maze,
maciej.wieczor-retman, joonki.min, glider, dvyukov, andreyknvl,
ryabinin.a.a, akpm
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5043 bytes --]
The patch titled
Subject: mm-kasan-fix-kasan-poisoning-in-vrealloc-fix
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
mm-kasan-fix-kasan-poisoning-in-vrealloc-fix.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-kasan-fix-kasan-poisoning-in-vrealloc-fix.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Subject: mm-kasan-fix-kasan-poisoning-in-vrealloc-fix
Date: Mon, 19 Jan 2026 15:45:09 +0100
Move kasan_enabled() check to header function to avoid function call if
kasan disabled via boot cmdline.
Move __kasan_vrealloc() to common.c to fix CONFIG_KASAN_HW_TAGS=y
Link: https://lkml.kernel.org/r/20260119144509.32767-1-ryabinin.a.a@gmail.com
Signed-off-by: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: <joonki.min@samsung-slsi.corp-partner.google.com>
Cc: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Cc: Maciej Żenczykowski <maze@google.com>
Cc: Uladzislau Rezki <urezki@gmail.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/kasan.h | 10 +++++++++-
mm/kasan/common.c | 21 +++++++++++++++++++++
mm/kasan/shadow.c | 24 ------------------------
3 files changed, 30 insertions(+), 25 deletions(-)
--- a/include/linux/kasan.h~mm-kasan-fix-kasan-poisoning-in-vrealloc-fix
+++ a/include/linux/kasan.h
@@ -641,9 +641,17 @@ kasan_unpoison_vmap_areas(struct vm_stru
__kasan_unpoison_vmap_areas(vms, nr_vms, flags);
}
-void kasan_vrealloc(const void *start, unsigned long old_size,
+void __kasan_vrealloc(const void *start, unsigned long old_size,
unsigned long new_size);
+static __always_inline void kasan_vrealloc(const void *start,
+ unsigned long old_size,
+ unsigned long new_size)
+{
+ if (kasan_enabled())
+ __kasan_vrealloc(start, old_size, new_size);
+}
+
#else /* CONFIG_KASAN_VMALLOC */
static inline void kasan_populate_early_vm_area_shadow(void *start,
--- a/mm/kasan/common.c~mm-kasan-fix-kasan-poisoning-in-vrealloc-fix
+++ a/mm/kasan/common.c
@@ -606,4 +606,25 @@ void __kasan_unpoison_vmap_areas(struct
__kasan_unpoison_vmalloc(addr, size, flags | KASAN_VMALLOC_KEEP_TAG);
}
}
+
+void __kasan_vrealloc(const void *addr, unsigned long old_size,
+ unsigned long new_size)
+{
+ if (new_size < old_size) {
+ kasan_poison_last_granule(addr, new_size);
+
+ new_size = round_up(new_size, KASAN_GRANULE_SIZE);
+ old_size = round_up(old_size, KASAN_GRANULE_SIZE);
+ if (new_size < old_size)
+ __kasan_poison_vmalloc(addr + new_size,
+ old_size - new_size);
+ } else if (new_size > old_size) {
+ old_size = round_down(old_size, KASAN_GRANULE_SIZE);
+ __kasan_unpoison_vmalloc(addr + old_size,
+ new_size - old_size,
+ KASAN_VMALLOC_PROT_NORMAL |
+ KASAN_VMALLOC_VM_ALLOC |
+ KASAN_VMALLOC_KEEP_TAG);
+ }
+}
#endif
--- a/mm/kasan/shadow.c~mm-kasan-fix-kasan-poisoning-in-vrealloc-fix
+++ a/mm/kasan/shadow.c
@@ -651,30 +651,6 @@ void __kasan_poison_vmalloc(const void *
kasan_poison(start, size, KASAN_VMALLOC_INVALID, false);
}
-void kasan_vrealloc(const void *addr, unsigned long old_size,
- unsigned long new_size)
-{
- if (!kasan_enabled())
- return;
-
- if (new_size < old_size) {
- kasan_poison_last_granule(addr, new_size);
-
- new_size = round_up(new_size, KASAN_GRANULE_SIZE);
- old_size = round_up(old_size, KASAN_GRANULE_SIZE);
- if (new_size < old_size)
- __kasan_poison_vmalloc(addr + new_size,
- old_size - new_size);
- } else if (new_size > old_size) {
- old_size = round_down(old_size, KASAN_GRANULE_SIZE);
- __kasan_unpoison_vmalloc(addr + old_size,
- new_size - old_size,
- KASAN_VMALLOC_PROT_NORMAL |
- KASAN_VMALLOC_VM_ALLOC |
- KASAN_VMALLOC_KEEP_TAG);
- }
-}
-
#else /* CONFIG_KASAN_VMALLOC */
int kasan_alloc_module_shadow(void *addr, size_t size, gfp_t gfp_mask)
_
Patches currently in -mm which might be from ryabinin.a.a@gmail.com are
mm-kasan-fix-kasan-poisoning-in-vrealloc.patch
mm-kasan-fix-kasan-poisoning-in-vrealloc-fix.patch
mm-kasan-kunit-extend-vmalloc-oob-tests-to-cover-vrealloc.patch
mm-kasan-kunit-extend-vmalloc-oob-tests-to-cover-vrealloc-fix.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-19 18:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 18:04 + mm-kasan-fix-kasan-poisoning-in-vrealloc-fix.patch added to mm-hotfixes-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.