Message ID | d6ba060f18999a00052180c2c10536226b50438a.1654011120.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/3] mm: rename kernel_init_free_pages to kernel_init_pages | expand |
On Tue, 31 May 2022 17:43:49 +0200 andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov <andreyknvl@google.com> > > Add a clear_highpage_tagged() helper that does clear_highpage() on a > page potentially tagged by KASAN. clear_highpage_kasan_tagged() would be a better name, no? --- a/include/linux/highmem.h~mm-introduce-clear_highpage_tagged-fix +++ a/include/linux/highmem.h @@ -243,7 +243,7 @@ static inline void clear_highpage(struct kunmap_local(kaddr); } -static inline void clear_highpage_tagged(struct page *page) +static inline void clear_highpage_kasan_tagged(struct page *page) { u8 tag; --- a/mm/page_alloc.c~mm-introduce-clear_highpage_tagged-fix +++ a/mm/page_alloc.c @@ -1311,7 +1311,7 @@ static void kernel_init_pages(struct pag /* s390's use of memset() could override KASAN redzones. */ kasan_disable_current(); for (i = 0; i < numpages; i++) - clear_highpage_tagged(page + i); + clear_highpage_kasan_tagged(page + i); kasan_enable_current(); }
On Tue, May 31, 2022 at 7:52 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Tue, 31 May 2022 17:43:49 +0200 andrey.konovalov@linux.dev wrote: > > > From: Andrey Konovalov <andreyknvl@google.com> > > > > Add a clear_highpage_tagged() helper that does clear_highpage() on a > > page potentially tagged by KASAN. > > clear_highpage_kasan_tagged() would be a better name, no? Sounds good! Will include into v2. I also noticed there's an extra empty line at the end of the function I need to fix. > > --- a/include/linux/highmem.h~mm-introduce-clear_highpage_tagged-fix > +++ a/include/linux/highmem.h > @@ -243,7 +243,7 @@ static inline void clear_highpage(struct > kunmap_local(kaddr); > } > > -static inline void clear_highpage_tagged(struct page *page) > +static inline void clear_highpage_kasan_tagged(struct page *page) > { > u8 tag; > > --- a/mm/page_alloc.c~mm-introduce-clear_highpage_tagged-fix > +++ a/mm/page_alloc.c > @@ -1311,7 +1311,7 @@ static void kernel_init_pages(struct pag > /* s390's use of memset() could override KASAN redzones. */ > kasan_disable_current(); > for (i = 0; i < numpages; i++) > - clear_highpage_tagged(page + i); > + clear_highpage_kasan_tagged(page + i); > kasan_enable_current(); > } > > _ >
diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 3af34de54330..df76a0db7cec 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -243,6 +243,17 @@ static inline void clear_highpage(struct page *page) kunmap_local(kaddr); } +static inline void clear_highpage_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 static inline void tag_clear_highpage(struct page *page) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 66ef8c310dce..d82ea983a7a3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1302,12 +1302,8 @@ static void kernel_init_pages(struct page *page, int numpages) /* s390's use of memset() could override KASAN redzones. */ kasan_disable_current(); - for (i = 0; i < numpages; i++) { - u8 tag = page_kasan_tag(page + i); - page_kasan_tag_reset(page + i); - clear_highpage(page + i); - page_kasan_tag_set(page + i, tag); - } + for (i = 0; i < numpages; i++) + clear_highpage_tagged(page + i); kasan_enable_current(); }