* [PATCH mm] kfence: zero guard page after out-of-bounds access
@ 2021-03-12 12:16 Marco Elver
2021-03-12 13:11 ` Alexander Potapenko
0 siblings, 1 reply; 2+ messages in thread
From: Marco Elver @ 2021-03-12 12:16 UTC (permalink / raw)
To: elver, akpm
Cc: glider, dvyukov, andreyknvl, jannh, linux-kernel, linux-mm, kasan-dev
After an out-of-bounds accesses, zero the guard page before
re-protecting in kfence_guarded_free(). On one hand this helps make the
failure mode of subsequent out-of-bounds accesses more deterministic,
but could also prevent certain information leaks.
Signed-off-by: Marco Elver <elver@google.com>
---
mm/kfence/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 3b8ec938470a..f7106f28443d 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -371,6 +371,7 @@ static void kfence_guarded_free(void *addr, struct kfence_metadata *meta, bool z
/* Restore page protection if there was an OOB access. */
if (meta->unprotected_page) {
+ memzero_explicit((void *)ALIGN_DOWN(meta->unprotected_page, PAGE_SIZE), PAGE_SIZE);
kfence_protect(meta->unprotected_page);
meta->unprotected_page = 0;
}
--
2.31.0.rc2.261.g7f71774620-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH mm] kfence: zero guard page after out-of-bounds access
2021-03-12 12:16 [PATCH mm] kfence: zero guard page after out-of-bounds access Marco Elver
@ 2021-03-12 13:11 ` Alexander Potapenko
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Potapenko @ 2021-03-12 13:11 UTC (permalink / raw)
To: Marco Elver
Cc: Andrew Morton, Dmitriy Vyukov, Andrey Konovalov, Jann Horn, LKML,
Linux Memory Management List, kasan-dev
On Fri, Mar 12, 2021 at 1:16 PM Marco Elver <elver@google.com> wrote:
>
> After an out-of-bounds accesses, zero the guard page before
> re-protecting in kfence_guarded_free(). On one hand this helps make the
> failure mode of subsequent out-of-bounds accesses more deterministic,
> but could also prevent certain information leaks.
>
> Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Alexander Potapenko <glider@google.com>
> ---
> mm/kfence/core.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/kfence/core.c b/mm/kfence/core.c
> index 3b8ec938470a..f7106f28443d 100644
> --- a/mm/kfence/core.c
> +++ b/mm/kfence/core.c
> @@ -371,6 +371,7 @@ static void kfence_guarded_free(void *addr, struct kfence_metadata *meta, bool z
>
> /* Restore page protection if there was an OOB access. */
> if (meta->unprotected_page) {
> + memzero_explicit((void *)ALIGN_DOWN(meta->unprotected_page, PAGE_SIZE), PAGE_SIZE);
> kfence_protect(meta->unprotected_page);
> meta->unprotected_page = 0;
> }
> --
> 2.31.0.rc2.261.g7f71774620-goog
>
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-12 13:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 12:16 [PATCH mm] kfence: zero guard page after out-of-bounds access Marco Elver
2021-03-12 13:11 ` Alexander Potapenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).