summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2020-01-17 18:48:39 +0300
committerWill Deacon <will@kernel.org>2020-01-17 19:05:50 +0300
commitc2c24edb1d9c308011f5a1328563d8da8c92c849 (patch)
tree2b2438f62417db3238cb88b111fe24120fab8880 /arch
parent5777eaed566a1d63e344d3dd8f2b5e33be20643e (diff)
downloadlinux-c2c24edb1d9c308011f5a1328563d8da8c92c849.tar.xz
arm64: csum: Fix pathological zero-length calls
In validating the checksumming results of the new routine, I sadly neglected to test its not-checksumming results. Thus it slipped through that the one case where @buff is already dword-aligned and @len = 0 manages to defeat the tail-masking logic and behave as if @len = 8. For a zero length it doesn't make much sense to deference @buff anyway, so just add an early return (which has essentially zero impact on performance). Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/lib/csum.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm64/lib/csum.c b/arch/arm64/lib/csum.c
index 847eb725ce09..1f82c66b32ea 100644
--- a/arch/arm64/lib/csum.c
+++ b/arch/arm64/lib/csum.c
@@ -20,6 +20,9 @@ unsigned int do_csum(const unsigned char *buff, int len)
const u64 *ptr;
u64 data, sum64 = 0;
+ if (unlikely(len == 0))
+ return 0;
+
offset = (unsigned long)buff & 7;
/*
* This is to all intents and purposes safe, since rounding down cannot