Skip to content

Commit c2c24ed

Browse files
rmurphy-armwilldeacon
authored andcommitted
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 <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 5777eae commit c2c24ed

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/arm64/lib/csum.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ unsigned int do_csum(const unsigned char *buff, int len)
2020
const u64 *ptr;
2121
u64 data, sum64 = 0;
2222

23+
if (unlikely(len == 0))
24+
return 0;
25+
2326
offset = (unsigned long)buff & 7;
2427
/*
2528
* This is to all intents and purposes safe, since rounding down cannot

0 commit comments

Comments
 (0)