Skip to content

Commit

Permalink
kasan: test: avoid corrupting memory in kasan_rcu_uaf
Browse files Browse the repository at this point in the history
kasan_rcu_uaf() writes to freed memory via kasan_rcu_reclaim(), which is
only safe with the GENERIC mode (as it uses quarantine).  For other modes,
this test corrupts kernel memory, which might result in a crash.

Turn the write into a read.

Link: https://lkml.kernel.org/r/b6f2c3bf712d2457c783fa59498225b66a634f62.1628779805.git.andreyknvl@gmail.com
Signed-off-by: Andrey Konovalov <[email protected]>
Reviewed-by: Marco Elver <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
xairy authored and torvalds committed Sep 3, 2021
1 parent 756e5a4 commit f16de0b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/test_kasan_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static noinline void __init kasan_rcu_reclaim(struct rcu_head *rp)
struct kasan_rcu_info, rcu);

kfree(fp);
fp->i = 1;
((volatile struct kasan_rcu_info *)fp)->i;
}

static noinline void __init kasan_rcu_uaf(void)
Expand Down

0 comments on commit f16de0b

Please sign in to comment.