This is a note to let you know that I've just added the patch titled compiler.h: Add read_word_at_a_time() function. to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: compiler.h-add-read_word_at_a_time-function.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Thu Oct 22 03:56:50 PM CEST 2020 From: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Date: Thu, 1 Feb 2018 21:00:49 +0300 Subject: compiler.h: Add read_word_at_a_time() function. From: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> commit 7f1e541fc8d57a143dd5df1d0a1276046e08c083 upstream. Sometimes we know that it's safe to do potentially out-of-bounds access because we know it won't cross a page boundary. Still, KASAN will report this as a bug. Add read_word_at_a_time() function which is supposed to be used in such cases. In read_word_at_a_time() KASAN performs relaxed check - only the first byte of access is validated. Signed-off-by: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> [bwh: Backported to 4.4: adjust context] Signed-off-by: Ben Hutchings <ben.hutchings@xxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- include/linux/compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -292,6 +292,7 @@ static __always_inline void __write_once * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ +#include <linux/kasan-checks.h> #define __READ_ONCE(x, check) \ ({ \ @@ -310,6 +311,13 @@ static __always_inline void __write_once */ #define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) +static __no_kasan_or_inline +unsigned long read_word_at_a_time(const void *addr) +{ + kasan_check_read(addr, 1); + return *(unsigned long *)addr; +} + #define WRITE_ONCE(x, val) \ ({ \ union { typeof(x) __val; char __c[1]; } __u = \ Patches currently in stable-queue which might be from aryabinin@xxxxxxxxxxxxx are queue-4.4/x86-mm-ptdump-fix-soft-lockup-in-page-table-walker.patch queue-4.4/mm-kasan-add-api-to-check-memory-regions.patch queue-4.4/compiler.h-add-read_word_at_a_time-function.patch queue-4.4/compiler.h-kasan-avoid-duplicating-__read_once_size_nocheck.patch queue-4.4/mm-kasan-print-name-of-mem-caller-in-report.patch queue-4.4/lib-strscpy-shut-up-kasan-false-positives-in-strscpy.patch