Thread (47 messages) flat view 47 messages, 5 authors, 2021-01-15

Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL

From: Andrey Konovalov <hidden>
Date: 2021-01-12 22:01:54
Also in: linux-mm, lkml

On Tue, Jan 12, 2021 at 8:50 PM Andrey Konovalov [off-list ref] wrote:
On Tue, Jan 12, 2021 at 9:18 AM Alexander Potapenko [off-list ref] wrote:
quoted
On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov [off-list ref] wrote:
quoted
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.
quoted
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.
Ah, actually no, it reorders the expression and puts it after
fail_data fields checks. That's why I put the barriers.
quoted
Note that compiler barriers won't probably help against removing
memory accesses, they only prevent reordering.
But using WRITE/READ_ONCE() might also be a good idea, as technically
the compiler can optimize away the accesses.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help