Messages in this thread | | | Date | Thu, 4 Feb 2016 17:39:16 -0800 | Subject | Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 | From | Linus Torvalds <> |
| |
On Thu, Feb 4, 2016 at 5:27 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote: > sum = csum_partial_lt8(*(unsigned long *)buff, len, sum); > return rotate_by8_if_odd(sum, align);
Actually, that last word-sized access to "buff" might be past the end of the buffer. The code does the right thing if "len" is zero, except for the possible page fault or address verifier complaint.
So that very last call to "csum_partial_lt8()" either needs to be conditional (easy enough to add an "if (len)" around that whole statement) or the thing could be unconditional but the load needs to use "load_unaligned_zeropad()" so that the exception is harmless.
It's probably immaterial which one you pick. The few possibly useless ALU operations vs a possible branch misprodict penalty are probably going to make it a wash. The exception will never happen in practice, but if DEBUG_PAGEALLOC is enabled, or if something like KASAN is active, it will complain loudly if it happens to go past the allocation.
Linus
| |