Commit 78c3f3bc authored by Vincenzo Frascino's avatar Vincenzo Frascino Committed by Peter Collingbourne
Browse files

FROMGIT: kasan: Add strscpy() test to trigger tag fault on arm64



When we invoke strscpy() with a maximum size of N bytes, it assumes
that:
- It can always read N bytes from the source.
- It always write N bytes (zero-padded) to the destination.

On aarch64 with Memory Tagging Extension enabled if we pass an N that is
bigger then the source buffer, it would previously trigger an MTE fault.

Implement a KASAN KUnit test that triggers the issue with the previous
implementation of read_word_at_a_time() on aarch64 with MTE enabled.

Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Co-developed-by: default avatarPeter Collingbourne <pcc@google.com>
Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
Link: https://linux-review.googlesource.com/id/If88e396b9e7c058c1a4b5a252274120e77b1898a


Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20250403000703.2584581-3-pcc@google.com


Signed-off-by: default avatarKees Cook <kees@kernel.org>
Bug: 400752037
(cherry picked from commit 48ac25ef250da7478ea54afbb1aced40c342e78d
 https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening)
Change-Id: If88e396b9e7c058c1a4b5a252274120e77b1898a
parent b5223b5d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment