Skip to content

Commit 94868a1

Browse files
melvertorvalds
authored andcommitted
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/[email protected] Signed-off-by: Marco Elver <[email protected]> Acked-by: Alexander Potapenko <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Jann Horn <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0c4ff27 commit 94868a1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/kfence/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ static void kfence_guarded_free(void *addr, struct kfence_metadata *meta, bool z
372372

373373
/* Restore page protection if there was an OOB access. */
374374
if (meta->unprotected_page) {
375+
memzero_explicit((void *)ALIGN_DOWN(meta->unprotected_page, PAGE_SIZE), PAGE_SIZE);
375376
kfence_protect(meta->unprotected_page);
376377
meta->unprotected_page = 0;
377378
}

0 commit comments

Comments
 (0)