[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAeHK+yFw5YcR1jAYbE+PSLc0NowCv88mS8kJLspe_RkSjX37w@mail.gmail.com>
Date: Tue, 12 Jan 2021 20:50:54 +0100
From: Andrey Konovalov <andreyknvl@...gle.com>
To: Alexander Potapenko <glider@...gle.com>
Cc: Catalin Marinas <catalin.marinas@....com>,
Vincenzo Frascino <vincenzo.frascino@....com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Marco Elver <elver@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Will Deacon <will.deacon@....com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Evgenii Stepanov <eugenis@...gle.com>,
Branislav Rankov <Branislav.Rankov@....com>,
Kevin Brodsky <kevin.brodsky@....com>,
kasan-dev <kasan-dev@...glegroups.com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
Linux Memory Management List <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL
On Tue, Jan 12, 2021 at 9:18 AM Alexander Potapenko <glider@...gle.com> wrote:
>
> On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
> >
> > It might not be obvious to the compiler that the expression must be
> > executed between writing and reading to fail_data. In this case, the
> > compiler might reorder or optimize away some of the accesses, and
> > the tests will fail.
>
> Have you seen this happen in practice?
Yes.
> Are these accesses to fail_data that are optimized (in which case we
> could make it volatile)?
Yes. AFAIU compiler doesn't expect expression to change fail_data
fields, no those accesses and checks are optimized away.
> Note that compiler barriers won't probably help against removing
> memory accesses, they only prevent reordering.
>
> > + barrier(); \
> > expression; \
> > + barrier(); \
>
> The need for barriers is not obvious to the reader, so a comment in
> the code clarifying that would be nice.
Will add a comment in v2, thanks!
Powered by blists - more mailing lists