diff --git a/patches.suse/arm64-csum-Disable-KASAN-for-do_csum.patch b/patches.suse/arm64-csum-Disable-KASAN-for-do_csum.patch new file mode 100644 index 0000000..26c936e --- /dev/null +++ b/patches.suse/arm64-csum-Disable-KASAN-for-do_csum.patch @@ -0,0 +1,84 @@ +From c6a771d932332568df9f46a3b53507c578e8c8e8 Mon Sep 17 00:00:00 2001 +From: Will Deacon +Date: Tue, 14 Apr 2020 22:22:47 +0100 +Subject: [PATCH] arm64: csum: Disable KASAN for do_csum() +Git-commit: c6a771d932332568df9f46a3b53507c578e8c8e8 +Patch-mainline: v5.8-rc1 +References: bsc#1177591 + +do_csum() over-reads the source buffer and therefore abuses +READ_ONCE_NOCHECK() to avoid tripping up KASAN. In preparation for +READ_ONCE_NOCHECK() becoming a macro, and therefore losing its +'__no_sanitize_address' annotation, just annotate do_csum() explicitly +and fall back to normal loads. + +Cc: Mark Rutland +Cc: Robin Murphy +Signed-off-by: Will Deacon +Acked-by: Jessica Yu +--- + arch/arm64/lib/csum.c | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/arch/arm64/lib/csum.c b/arch/arm64/lib/csum.c +index 60eccae2abad..78b87a64ca0a 100644 +--- a/arch/arm64/lib/csum.c ++++ b/arch/arm64/lib/csum.c +@@ -14,7 +14,11 @@ static u64 accumulate(u64 sum, u64 data) + return tmp + (tmp >> 64); + } + +-unsigned int do_csum(const unsigned char *buff, int len) ++/* ++ * We over-read the buffer and this makes KASAN unhappy. Instead, disable ++ * instrumentation and call kasan explicitly. ++ */ ++unsigned int __no_sanitize_address do_csum(const unsigned char *buff, int len) + { + unsigned int offset, shift, sum; + const u64 *ptr; +@@ -42,7 +46,7 @@ unsigned int do_csum(const unsigned char *buff, int len) + * odd/even alignment, and means we can ignore it until the very end. + */ + shift = offset * 8; +- data = READ_ONCE_NOCHECK(*ptr++); ++ data = *ptr++; + #ifdef __LITTLE_ENDIAN + data = (data >> shift) << shift; + #else +@@ -58,10 +62,10 @@ unsigned int do_csum(const unsigned char *buff, int len) + while (unlikely(len > 64)) { + __uint128_t tmp1, tmp2, tmp3, tmp4; + +- tmp1 = READ_ONCE_NOCHECK(*(__uint128_t *)ptr); +- tmp2 = READ_ONCE_NOCHECK(*(__uint128_t *)(ptr + 2)); +- tmp3 = READ_ONCE_NOCHECK(*(__uint128_t *)(ptr + 4)); +- tmp4 = READ_ONCE_NOCHECK(*(__uint128_t *)(ptr + 6)); ++ tmp1 = *(__uint128_t *)ptr; ++ tmp2 = *(__uint128_t *)(ptr + 2); ++ tmp3 = *(__uint128_t *)(ptr + 4); ++ tmp4 = *(__uint128_t *)(ptr + 6); + + len -= 64; + ptr += 8; +@@ -85,7 +89,7 @@ unsigned int do_csum(const unsigned char *buff, int len) + __uint128_t tmp; + + sum64 = accumulate(sum64, data); +- tmp = READ_ONCE_NOCHECK(*(__uint128_t *)ptr); ++ tmp = *(__uint128_t *)ptr; + + len -= 16; + ptr += 2; +@@ -100,7 +104,7 @@ unsigned int do_csum(const unsigned char *buff, int len) + } + if (len > 0) { + sum64 = accumulate(sum64, data); +- data = READ_ONCE_NOCHECK(*ptr); ++ data = *ptr; + len -= 8; + } + /* +-- +2.16.4 + diff --git a/series.conf b/series.conf index 47846ed..0640897 100644 --- a/series.conf +++ b/series.conf @@ -24824,6 +24824,7 @@ patches.suse/netfilter-Avoid-assigning-const-pointer-to-non-const.patch patches.suse/net-tls-Avoid-assigning-const-pointer-to-non-const-p.patch patches.suse/fault_inject-Don-t-rely-on-return-value-from-WRITE_O.patch + patches.suse/arm64-csum-Disable-KASAN-for-do_csum.patch patches.suse/READ_ONCE-Simplify-implementations-of-READ-WRITE-_ON.patch patches.suse/READ_ONCE-Enforce-atomicity-for-READ-WRITE-_ONCE-mem.patch patches.suse/READ_ONCE-Drop-pointer-qualifiers-when-reading-from-.patch