Commit b5223b5d authored by Peter Collingbourne's avatar Peter Collingbourne
Browse files

FROMGIT: string: Add load_unaligned_zeropad() code path to sized_strscpy()



The call to read_word_at_a_time() in sized_strscpy() is problematic
with MTE because it may trigger a tag check fault when reading
across a tag granule (16 bytes) boundary. To make this code
MTE compatible, let's start using load_unaligned_zeropad()
on architectures where it is available (i.e. architectures that
define CONFIG_DCACHE_WORD_ACCESS). Because load_unaligned_zeropad()
takes care of page boundaries as well as tag granule boundaries,
also disable the code preventing crossing page boundaries when using
load_unaligned_zeropad().

Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/If4b22e43b5a4ca49726b4bf98ada827fdf755548


Fixes: 94ab5b61 ("kasan, arm64: enable CONFIG_KASAN_HW_TAGS")
Cc: stable@vger.kernel.org
Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20250403000703.2584581-2-pcc@google.com


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