Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(49)

Issue 14271043: GCC KASAN patch

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 6 months ago by andreyknvl
Modified:
11 years ago
Reviewers:
yunlian, bjanakiraman, vapier1, vapier, wmi, llozano, davidxl, preobr, Diego Novillo, dvyukov
CC:
kcc
Base URL:
svn://gcc.gnu.org/svn/gcc/trunk/
Visibility:
Public.

Description

This patch adds AddressSanitizer for kernel instrumentation support to gcc (-fsanitize=kernel-address flag). AddressSanitizer for kernel uses ThreadSanitizer pass (tsan.c) because the instrumentation is not finalized yet and we would like to have function calls instead of inlined instrumentation. In future AddressSanitizer for Linux kernel will likely move to asan.c

Patch Set 1 #

Patch Set 2 : Comment added #

Patch Set 3 : Comment updated #

Total comments: 13

Patch Set 4 : Fixed #

Unified diffs Side-by-side diffs Delta from patch set Stats (+86 lines, -20 lines) Patch
M gcc/builtins.def View 1 chunk +2 lines, -2 lines 0 comments Download
M gcc/doc/invoke.texi View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
M gcc/flag-types.h View 1 2 3 1 chunk +3 lines, -1 line 0 comments Download
M gcc/gcc.c View 1 2 3 2 chunks +4 lines, -1 line 0 comments Download
M gcc/opts.c View 1 chunk +2 lines, -0 lines 0 comments Download
M gcc/sanitizer.def View 1 chunk +22 lines, -0 lines 0 comments Download
M gcc/toplev.c View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M gcc/tsan.c View 1 2 3 4 chunks +43 lines, -16 lines 0 comments Download

Messages

Total messages: 20
andreyknvl
Please review.
11 years, 6 months ago (2013-10-02 09:31:39 UTC) #1
andreyknvl
Please take a look at the comment in tsan.c
11 years, 6 months ago (2013-10-02 10:58:33 UTC) #2
kcc
Add: In future AddressSanitizer for Kernel will likely move to asan.c On Wed, Oct 2, ...
11 years, 6 months ago (2013-10-02 11:00:16 UTC) #3
andreyknvl
Hi! This is a patch that adds AddressSanitizer for kernel support to gcc. Please review.
11 years, 6 months ago (2013-10-02 11:12:01 UTC) #4
davidxl
Why not submitting it to GCC trunk first? kcc@ and dmitry are the project's maintainer ...
11 years, 6 months ago (2013-10-02 15:02:14 UTC) #5
dvyukov
We will, but we want internal pre-review first. On Wed, Oct 2, 2013 at 7:02 ...
11 years, 6 months ago (2013-10-02 15:06:07 UTC) #6
davidxl
https://codereview.appspot.com/14271043/diff/11001/gcc/toplev.c File gcc/toplev.c (right): https://codereview.appspot.com/14271043/diff/11001/gcc/toplev.c#newcode580 gcc/toplev.c:580: tsan_finish_file (); WHen kernel address sanitizer is on, why ...
11 years, 6 months ago (2013-10-02 16:03:40 UTC) #7
davidxl
11 years, 6 months ago (2013-10-02 16:04:13 UTC) #8
vapier1
https://codereview.appspot.com/14271043/diff/11001/gcc/doc/invoke.texi File gcc/doc/invoke.texi (right): https://codereview.appspot.com/14271043/diff/11001/gcc/doc/invoke.texi#newcode5235 gcc/doc/invoke.texi:5235: Enable AddressSanitizer for Linux kernel, a fast memory error ...
11 years, 6 months ago (2013-10-02 17:47:50 UTC) #9
dvyukov
https://codereview.appspot.com/14271043/diff/11001/gcc/tsan.c File gcc/tsan.c (right): https://codereview.appspot.com/14271043/diff/11001/gcc/tsan.c#newcode45 gcc/tsan.c:45: the instrumentation is not finalized yet and we would ...
11 years, 6 months ago (2013-10-08 17:42:40 UTC) #10
bjanakiraman_google.com
Hi Dmitry, I don't understand 'temporal implementation'. Is this meant to be stop-gap, and if ...
11 years, 6 months ago (2013-10-08 20:03:07 UTC) #11
andreyknvl
Please review again. https://codereview.appspot.com/14271043/diff/11001/gcc/doc/invoke.texi File gcc/doc/invoke.texi (right): https://codereview.appspot.com/14271043/diff/11001/gcc/doc/invoke.texi#newcode5235 gcc/doc/invoke.texi:5235: Enable AddressSanitizer for Linux kernel, a ...
11 years, 6 months ago (2013-10-09 12:27:44 UTC) #12
dvyukov
On 2013/10/08 20:03:07, bjanakiraman_google.com wrote: > Hi Dmitry, > I don't understand 'temporal implementation'. Is ...
11 years, 6 months ago (2013-10-10 12:02:40 UTC) #13
davidxl
The change is ok for Google v17 branch for now. David On Thu, Oct 10, ...
11 years, 6 months ago (2013-10-10 18:18:30 UTC) #14
preobr
Hi, we are interested in submitting this change to crosstool. Should we go through another ...
11 years ago (2014-03-26 18:55:02 UTC) #15
davidxl
Please submit another one to gcc-patches@, cc Dmitry and me. thanks, David On Wed, Mar ...
11 years ago (2014-03-26 18:57:04 UTC) #16
dvyukov
What branch do we need to use as base now? On Wed, Mar 26, 2014 ...
11 years ago (2014-03-26 18:59:57 UTC) #17
davidxl
still google/gcc-4_8. The subject line should starts with [GOOGLE]: thanks, David On Wed, Mar 26, ...
11 years ago (2014-03-26 19:01:48 UTC) #18
preobr
This patch will not fit on top of google/gcc-4_8 (it modifies enum sanitize_code in gcc/flag-types.h, ...
11 years ago (2014-03-26 19:20:50 UTC) #19
davidxl
11 years ago (2014-03-26 19:38:14 UTC) #20
That depends on what compiler you plan to use this functionality. If
it is v17, then you need to port it to google/gcc-4_8 (with dependent
patches backported). Otherwise google/main is fine.

David

On Wed, Mar 26, 2014 at 12:20 PM, Alexey Preobrazhensky
<preobr@google.com> wrote:
> This patch will not fit on top of google/gcc-4_8
> (it modifies enum sanitize_code in gcc/flag-types.h, which is not present in
> google/gcc-4_8).
>
> Should I base it on google/gcc-4_9 or google/main?
>
> On Wed, Mar 26, 2014 at 11:01 PM, Xinliang David Li <davidxl@google.com>
> wrote:
>>
>> still google/gcc-4_8.
>>
>> The subject line should starts with [GOOGLE]:
>>
>> thanks,
>>
>> David
>>
>> On Wed, Mar 26, 2014 at 11:59 AM, Dmitry Vyukov <dvyukov@google.com>
>> wrote:
>> > What branch do we need to use as base now?
>> >
>> >
>> > On Wed, Mar 26, 2014 at 10:57 PM, Xinliang David Li <davidxl@google.com>
>> > wrote:
>> >> Please submit another one to gcc-patches@, cc Dmitry and me.
>> >>
>> >> thanks,
>> >>
>> >> David
>> >>
>> >> On Wed, Mar 26, 2014 at 11:55 AM,  <preobr@google.com> wrote:
>> >>> Hi,
>> >>>
>> >>> we are interested in submitting this change to crosstool.
>> >>> Should we go through another review or just rebase and submit?
>> >>>
>> >>> Where is Google v17 branch?
>> >>>
>> >>> Alexey
>> >>>
>> >>> On 2013/10/10 18:18:30, davidxl wrote:
>> >>>>
>> >>>> The change is ok for Google v17 branch for now.
>> >>>
>> >>>
>> >>>> David
>> >>>
>> >>>
>> >>>> On Thu, Oct 10, 2013 at 5:02 AM,  <mailto:dvyukov@google.com> wrote:
>> >>>> > On 2013/10/08 20:03:07, http://bjanakiraman_google.com wrote:
>> >>>> >>
>> >>>> >> Hi Dmitry,
>> >>>> >> I don't understand 'temporal implementation'. Is this meant to be
>> >>>> >
>> >>>> > stop-gap,
>> >>>> >>
>> >>>> >> and if yes, for how long?
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> > Yes, this is a stop-gap.
>> >>>> > It's difficult to say for how long exactly. We want to hire a new
>> >>>> > developer for this project (which may happen next week), and then
>> >>>
>> >>> there
>> >>>>
>> >>>> > will be several potential directions: improve runtime, deployment
>> >>>
>> >>> into
>> >>>>
>> >>>> > prodkernel/ChromeOS, replace the stop-gap compiler instrumentation
>> >>>
>> >>> with
>> >>>>
>> >>>> > the final one.
>> >>>> > I would say it can be 1-6 months or so.
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >> Its great to have this functionality, but my preference is to get
>> >>>
>> >>> it
>> >>>>
>> >>>> >> upstream. It is a big re-write, or are you more worried about the
>> >>>> >
>> >>>> > process
>> >>>> >>
>> >>>> >> of upstreaming?
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> > I am more worried that it's a stop-gap solution, but at the same
>> >>>
>> >>> time we
>> >>>>
>> >>>> > want this in crosstool ASAP.
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >> On Tue, Oct 8, 2013 at 10:42 AM, <mailto:dvyukov@google.com>
>> >>>> >> wrote:
>> >>>> >
>> >>>> >
>> >>>> >> >
>> >>>> >> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>
>> >>>
>> >>>
>> >>>
https://codereview.appspot.**com/14271043/diff/11001/gcc/**tsan.c%3Chttps://c...>
>> >>>>
>> >>>> >>
>> >>>> >> > File gcc/tsan.c (right):
>> >>>> >> >
>> >>>> >> > https://codereview.appspot.**com/14271043/diff/11001/gcc/**
>> >>>> >> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>
>> >>>
>> >>>
>> >>>
tsan.c#newcode45<https://codereview.appspot.com/14271043/diff/11001/gcc/tsan.c#newcode45>
>> >>>>
>> >>>> >>
>> >>>> >> > gcc/tsan.c:45: the instrumentation is not finalized yet and we
>> >>>
>> >>> would
>> >>>>
>> >>>> >> > like to have
>> >>>> >> > On 2013/10/02 16:03:41, davidxl wrote:
>> >>>> >> >
>> >>>> >> >> I think this this is weird. It is better not mix address
>> >>>
>> >>> sanitizer
>> >>>>
>> >>>> >> >>
>> >>>> >> > code in
>> >>>> >> >
>> >>>> >> >> tsan.c.
>> >>>> >> >>
>> >>>> >> >
>> >>>> >> > Yes, this is weird.
>> >>>> >> > Eventually kasan will use asan instrumentation pass with some
>> >>>> >
>> >>>> > minimal
>> >>>> >>
>> >>>> >> > changes.
>> >>>> >> > But for now we want to get something into crosstool, so that
>> >>>> >> > it's
>> >>>> >> > available for prodkernel and ChromeOS. Upstream gcc is nice but
>> >>>
>> >>> not
>> >>>>
>> >>>> >> > particularly critical at this point.
>> >>>> >> > Taking into account that the current code is a temporal
>> >>>> >
>> >>>> > implementation,
>> >>>> >>
>> >>>> >> > it's unclear whether it makes sense to put a lot of effort into
>> >>>
>> >>> it.
>> >>>>
>> >>>> >> >
>> >>>> >> >
>> >>>> >> > https://codereview.appspot.**com/14271043/diff/11001/gcc/**
>> >>>> >> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>
>> >>>
>> >>>
>> >>>
tsan.c#newcode59<https://codereview.appspot.com/14271043/diff/11001/gcc/tsan.c#newcode59>
>> >>>>
>> >>>> >
>> >>>> >> > gcc/tsan.c:59: if ((flag_sanitize & SANITIZE_KERNEL_ADDRESS) ==
>> >>>
>> >>> 0)
>> >>>>
>> >>>> >> > On 2013/10/02 16:03:41, davidxl wrote:
>> >>>> >> >
>> >>>> >> >> Will this work when both thread sanitizer and kernel address
>> >>>> >
>> >>>> > sanitizer
>> >>>> >>
>> >>>> >> >>
>> >>>> >> > are
>> >>>> >> >
>> >>>> >> >> specified?
>> >>>> >> >>
>> >>>> >> >
>> >>>> >>
>> >>>> >> > asan, tsan and kasan are incompatible, you can not enable two of
>> >>>> >
>> >>>> > them
>> >>>> >>
>> >>>> >> > tsan and kasan are in particular incompatible -- will the
>> >>>
>> >>> resulting
>> >>>>
>> >>>> >> > binary run in user space of kernel space?
>> >>>> >> >
>> >>>> >> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>
>> >>>
>> >>>
>> >>>
https://codereview.appspot.**com/14271043/%3Chttps://codereview.appspot.com/1...>
>> >>>>
>> >>>> >>
>> >>>> >> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> > https://codereview.appspot.com/14271043/
>> >>>
>> >>>
>> >>>
>> >>> https://codereview.appspot.com/14271043/
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b