mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/chunkeey.git] / target / linux / generic / backport-5.4 / 042-v5.5-arm64-csum-Fix-pathological-zero-length-calls.patch
1 From: Robin Murphy <robin.murphy@arm.com>
2 Date: Fri, 17 Jan 2020 15:48:39 +0000
3 Subject: [PATCH] arm64: csum: Fix pathological zero-length calls
4
5 In validating the checksumming results of the new routine, I sadly
6 neglected to test its not-checksumming results. Thus it slipped through
7 that the one case where @buff is already dword-aligned and @len = 0
8 manages to defeat the tail-masking logic and behave as if @len = 8.
9 For a zero length it doesn't make much sense to deference @buff anyway,
10 so just add an early return (which has essentially zero impact on
11 performance).
12
13 Signed-off-by: Robin Murphy <robin.murphy@arm.com>
14 Signed-off-by: Will Deacon <will@kernel.org>
15 ---
16
17 --- a/arch/arm64/lib/csum.c
18 +++ b/arch/arm64/lib/csum.c
19 @@ -20,6 +20,9 @@ unsigned int do_csum(const unsigned char
20 const u64 *ptr;
21 u64 data, sum64 = 0;
22
23 + if (unlikely(len == 0))
24 + return 0;
25 +
26 offset = (unsigned long)buff & 7;
27 /*
28 * This is to all intents and purposes safe, since rounding down cannot