From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: <glider@google.com>, Dmitry Vyukov <dvyukov@google.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: kasan behavior when built with unsupported compiler
Date: Tue, 7 Mar 2017 19:23:12 +0300 [thread overview]
Message-ID: <b7d9fda7-4fbf-77d4-9950-a6f68c2138d8@virtuozzo.com> (raw)
In-Reply-To: <1eb0b1ba-3847-9bdc-8f4a-adcd34de3486@gmail.com>
On 03/07/2017 06:35 PM, Nikolay Borisov wrote:
> Hello,
>
> I've been chasing a particular UAF as reported by kasan
> (https://www.spinics.net/lists/kernel/msg2458136.html).
AFAICS it's not use after free, it's out-of-bounds access.
> However, one
> thing which I took notice of rather lately is that I was building my
> kernel with gcc 4.7.4 which is not supported by kasan as indicated by
> the following string:
>
> scripts/Makefile.kasan:19: Cannot use CONFIG_KASAN:
> -fsanitize=kernel-address is not supported by compiler
>
>
> Nevertheless, the kernel compiles and when I boot it I see the kasan
> splats as per the referenced thread.
With gcc like 4.7.4 compiler will not instrument memory accesses in code, which means
that kasan will not detect bugs. However, in your case, access is done via copy_to_user().
Compiler doesn't see accesses in copy_to_user() because it's written in assembly, thus
we added manual check in commit 1771c6e1a567ea0ba2cccc0a4ffe68a1419fd8ef.
Of course this manual check will work with any compiler version.
> If, however, I build the kernel
> with a newer compiler version 5.4.0 kasan no longer complains.
>
That's odd. Perhaps we have some tricky bug triggered by gcc 4.7.4 code generation
or it might be some bug in gcc. But it's just a blind guess, it's hard to say anything
for sure without further analysis.
>
> At this point I'm wondering whether the splats can be due to old
> compiler being used e.g. false positives or are they genuine splats and
> gcc 5 somehow obfuscates them ? Clearly despite the warning about not
> being able to use CONFIG_KASAN it is still working since I'm seeing the
> splats. Is this valid behavior ?
>
So with GCCs that doesn't support kasan we shouldn't have any false-positives,
but it's expected to have a lot of false-negatives (missed bugs).
>
> Regards,
> Nikolay
>
prev parent reply other threads:[~2017-03-07 16:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 15:35 Nikolay Borisov
2017-03-07 15:54 ` Dmitry Vyukov
2017-03-07 16:05 ` Alexander Potapenko
2017-03-07 17:33 ` Nikolay Borisov
2017-03-07 17:51 ` Alexander Potapenko
2017-03-07 20:24 ` Nikolay Borisov
2017-03-07 16:26 ` Andrey Ryabinin
2017-03-07 16:40 ` Dmitry Vyukov
2017-03-08 8:10 ` Nikolay Borisov
2017-03-08 12:34 ` Dmitry Vyukov
2017-03-09 9:46 ` Andrey Ryabinin
2017-03-09 9:47 ` Dmitry Vyukov
2017-03-09 9:58 ` Nikolay Borisov
2017-03-09 10:16 ` Dmitry Vyukov
2017-03-09 11:23 ` Andrey Ryabinin
2017-03-07 16:23 ` Andrey Ryabinin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7d9fda7-4fbf-77d4-9950-a6f68c2138d8@virtuozzo.com \
--to=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=n.borisov.lkml@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®