Re: [PATCH] lib/strscpy: avoid KASAN false positive
From: Linus Torvalds
Date: Tue Jul 18 2017 - 18:35:26 EST
On Tue, Jul 18, 2017 at 3:04 PM, Andrew Morton
<akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> We could just remove all that word-at-a-time logic. Do we have any
> evidence that this would harm anything?
One option would be to simply make reads more permissive, and only
check the first byte of the read (unlike the last, which is what it
does now). Obviously within the normal KASAN granularity level (which
I think is 8 byte aligned anyway).
Checking *writes* more carefully is obviously a good idea regardless.
But the whole "do big reads" is pretty common for a lot of memory and
string copies.
So maybe the whole KASAN_SHADOW_MASK thing could be limited to just
the write side?
That would certainly simplify things. How much it would hurt coverage
would be something that the people who have analyzed KASAN reports so
far would have to judge. Have any of the existing KASAN reports been
due to the KASAN_SHADOW_SCALE level read tests?
Linus