[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFz3RKH2WDJBihpOO5MrLMKZgOsRoNKR3jUUtecW6a1Ymw@mail.gmail.com>
Date: Tue, 18 Jul 2017 10:22:44 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Andrey Ryabinin <aryabinin@...tuozzo.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Dave Jones <davej@...emonkey.org.uk>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>, kasan-dev@...glegroups.com,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] lib/strscpy: avoid KASAN false positive
On Tue, Jul 18, 2017 at 10:15 AM, Andrey Ryabinin
<aryabinin@...tuozzo.com> wrote:
>
> + /*
> + * KASAN won't be happy about word-at-a-time
> + * optimistic reads, so let's avoid them.
> + */
> + if (IS_ENABLED(CONFIG_KASAN))
> + max = 0;
> +
No, please don't.
Two reasons:
(a) it turns out that KASAN doesn't actually warn about this when
there aren't buggy users (because we only do word-at-a-time in the
spacified-to-be-safe region anyway).
(b) havign automated testing that then just changes semantics and
implementation of what is tested is a bad bad bad idea.
So (a) says that we shouldn't need it in the first place, and (b) says
that we should avoid KASAN changing behavior unless we absolutely
*have* to.
In fact, I think we should *never* have that kind of "KASAN changes
semantics". If there is some particular load that is known to be
problematic for KASAN, we *still* shouldn't change semantics, we
should just mark that single load as being unchecked by KASAN.
Linus
Powered by blists - more mailing lists