mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
mm: introduce clear_highpage_kasan_tagged
commit d9da8f6cf5
upstream.
Add a clear_highpage_kasan_tagged() helper that does clear_highpage() on a
page potentially tagged by KASAN.
This helper is used by the following patch.
Link: https://lkml.kernel.org/r/4471979b46b2c487787ddcd08b9dc5fedd1b6ffd.1654798516.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
11e008e599
commit
043fcdc287
2 changed files with 12 additions and 6 deletions
|
@ -218,6 +218,16 @@ static inline void clear_highpage(struct page *page)
|
||||||
kunmap_local(kaddr);
|
kunmap_local(kaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void clear_highpage_kasan_tagged(struct page *page)
|
||||||
|
{
|
||||||
|
u8 tag;
|
||||||
|
|
||||||
|
tag = page_kasan_tag(page);
|
||||||
|
page_kasan_tag_reset(page);
|
||||||
|
clear_highpage(page);
|
||||||
|
page_kasan_tag_set(page, tag);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE
|
#ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE
|
||||||
|
|
||||||
static inline void tag_clear_highpage(struct page *page)
|
static inline void tag_clear_highpage(struct page *page)
|
||||||
|
|
|
@ -1287,12 +1287,8 @@ static void kernel_init_free_pages(struct page *page, int numpages)
|
||||||
|
|
||||||
/* s390's use of memset() could override KASAN redzones. */
|
/* s390's use of memset() could override KASAN redzones. */
|
||||||
kasan_disable_current();
|
kasan_disable_current();
|
||||||
for (i = 0; i < numpages; i++) {
|
for (i = 0; i < numpages; i++)
|
||||||
u8 tag = page_kasan_tag(page + i);
|
clear_highpage_kasan_tagged(page + i);
|
||||||
page_kasan_tag_reset(page + i);
|
|
||||||
clear_highpage(page + i);
|
|
||||||
page_kasan_tag_set(page + i, tag);
|
|
||||||
}
|
|
||||||
kasan_enable_current();
|
kasan_enable_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue