linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [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

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).