]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
string: Add load_unaligned_zeropad() code path to sized_strscpy()
authorPeter Collingbourne <pcc@google.com>
Thu, 3 Apr 2025 00:06:59 +0000 (17:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:28 +0000 (07:44 +0200)
commit14c96391dff0ac232a1647c7aed41b341474e4a7
treea6f7395ba5fbfc44bc87afacb8cee96f0adbda07
parent039b1d64c8ea6d35517c260633728752e88fec50
string: Add load_unaligned_zeropad() code path to sized_strscpy()

[ Upstream commit d94c12bd97d567de342fd32599e7cd9e50bfa140 ]

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: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/If4b22e43b5a4ca49726b4bf98ada827fdf755548
Fixes: 94ab5b61ee16 ("kasan, arm64: enable CONFIG_KASAN_HW_TAGS")
Cc: stable@vger.kernel.org
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20250403000703.2584581-2-pcc@google.com
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/string.c