From: Marco Elver Date: Wed, 5 May 2021 01:40:18 +0000 (-0700) Subject: kfence: zero guard page after out-of-bounds access X-Git-Tag: v5.15~1181^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94868a1e127bbe0e03a4467f27196cd668cbc344;p=platform%2Fkernel%2Flinux-starfive.git kfence: zero guard page after out-of-bounds access 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. Link: https://lkml.kernel.org/r/20210312121653.348518-1-elver@google.com Signed-off-by: Marco Elver Acked-by: Alexander Potapenko Cc: Dmitry Vyukov Cc: Andrey Konovalov Cc: Jann Horn Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/kfence/core.c b/mm/kfence/core.c index d53c91f..768dbd5 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -372,6 +372,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; }