linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kasan: add __asan_report_loadN/storeN_noabort callbacks
@ 2018-01-19 17:44 Andrey Konovalov
  2018-01-23 10:44 ` Andrey Ryabinin
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Konovalov @ 2018-01-19 17:44 UTC (permalink / raw)
  To: Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov, kasan-dev,
	linux-mm, linux-kernel
  Cc: Kostya Serebryany, Evgeniy Stepanov, Andrey Konovalov

Instead of __asan_report_load_n_noabort and __asan_report_store_n_noabort
callbacks Clang emits differently named __asan_report_loadN_noabort and
__asan_report_storeN_noabort (similar to __asan_loadN/storeN_noabort, whose
names both GCC and Clang agree on).

Add callback implementation for __asan_report_loadN/storeN_noabort.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
 mm/kasan/report.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index eff12e040498..caf4c9e948c6 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -450,3 +450,15 @@ void __asan_report_store_n_noabort(unsigned long addr, size_t size)
 	kasan_report(addr, size, true, _RET_IP_);
 }
 EXPORT_SYMBOL(__asan_report_store_n_noabort);
+
+void __asan_report_loadN_noabort(unsigned long addr, size_t size)
+{
+	kasan_report(addr, size, false, _RET_IP_);
+}
+EXPORT_SYMBOL(__asan_report_loadN_noabort);
+
+void __asan_report_storeN_noabort(unsigned long addr, size_t size)
+{
+	kasan_report(addr, size, true, _RET_IP_);
+}
+EXPORT_SYMBOL(__asan_report_storeN_noabort);
-- 
2.16.0.rc1.238.g530d649a79-goog

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kasan: add __asan_report_loadN/storeN_noabort callbacks
  2018-01-19 17:44 [PATCH] kasan: add __asan_report_loadN/storeN_noabort callbacks Andrey Konovalov
@ 2018-01-23 10:44 ` Andrey Ryabinin
  2018-01-23 15:34   ` Andrey Konovalov
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Ryabinin @ 2018-01-23 10:44 UTC (permalink / raw)
  To: Andrey Konovalov, Alexander Potapenko, Dmitry Vyukov, kasan-dev,
	linux-mm, linux-kernel
  Cc: Kostya Serebryany, Evgeniy Stepanov, Andrew Morton

On 01/19/2018 08:44 PM, Andrey Konovalov wrote:
> Instead of __asan_report_load_n_noabort and __asan_report_store_n_noabort
> callbacks Clang emits differently named __asan_report_loadN_noabort and
> __asan_report_storeN_noabort (similar to __asan_loadN/storeN_noabort, whose
> names both GCC and Clang agree on).
> 
> Add callback implementation for __asan_report_loadN/storeN_noabort.
> 

This made me wonder why this wasn't observed before. So I noticed that
inline instrumentation with -fsanitize=kernel-addresss is broken in clang,
and clang never calls __asan_report*() functions. I see that you guys fixed this
just yesterday https://reviews.llvm.org/D42384 .

But it seems that you didn't fix the rest of "if (CompileKernel)" crap.
Clang generates "__asan_report_[load,store]N*" instead of "__asan_report_[load,store]_n*"
only because of this idiocy:

	const std::string SuffixStr = CompileKernel ? "N" : "_n";

See https://github.com/llvm-mirror/llvm/blob/ca19eaabd75f55865efd321b7a6f1d4ba3db8bc8/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L2250

Note that SuffixStr is used *only* for __asan_report_* callbacks, which makes no sense because
we never ever had __asan_report* callbacks with "N" suffix.

So I think that you should just fix the llvm here.

And there is probably one more "if (CompileKernel)" crap in runOnModule()
which breaks globals instrumentation.



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kasan: add __asan_report_loadN/storeN_noabort callbacks
  2018-01-23 10:44 ` Andrey Ryabinin
@ 2018-01-23 15:34   ` Andrey Konovalov
  0 siblings, 0 replies; 3+ messages in thread
From: Andrey Konovalov @ 2018-01-23 15:34 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Alexander Potapenko, Dmitry Vyukov, kasan-dev,
	Linux Memory Management List, LKML, Kostya Serebryany,
	Evgeniy Stepanov, Andrew Morton

On Tue, Jan 23, 2018 at 11:44 AM, Andrey Ryabinin
<aryabinin@virtuozzo.com> wrote:
> On 01/19/2018 08:44 PM, Andrey Konovalov wrote:
>> Instead of __asan_report_load_n_noabort and __asan_report_store_n_noabort
>> callbacks Clang emits differently named __asan_report_loadN_noabort and
>> __asan_report_storeN_noabort (similar to __asan_loadN/storeN_noabort, whose
>> names both GCC and Clang agree on).
>>
>> Add callback implementation for __asan_report_loadN/storeN_noabort.
>>
>
> This made me wonder why this wasn't observed before. So I noticed that
> inline instrumentation with -fsanitize=kernel-addresss is broken in clang,
> and clang never calls __asan_report*() functions. I see that you guys fixed this
> just yesterday https://reviews.llvm.org/D42384 .

Correct.

>
> But it seems that you didn't fix the rest of "if (CompileKernel)" crap.
> Clang generates "__asan_report_[load,store]N*" instead of "__asan_report_[load,store]_n*"
> only because of this idiocy:
>
>         const std::string SuffixStr = CompileKernel ? "N" : "_n";
>
> See https://github.com/llvm-mirror/llvm/blob/ca19eaabd75f55865efd321b7a6f1d4ba3db8bc8/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L2250
>
> Note that SuffixStr is used *only* for __asan_report_* callbacks, which makes no sense because
> we never ever had __asan_report* callbacks with "N" suffix.
>
> So I think that you should just fix the llvm here.

I think you are right.

I thought that GCC uses different and inconsistent callback names for
the kernel and user space, but that doesn't seem to be the case.

I submitted an LLVM change: https://reviews.llvm.org/D42423

Please discard this patch.

>
> And there is probably one more "if (CompileKernel)" crap in runOnModule()
> which breaks globals instrumentation.

Right, this will be fixed at some point.

>
>
>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-23 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 17:44 [PATCH] kasan: add __asan_report_loadN/storeN_noabort callbacks Andrey Konovalov
2018-01-23 10:44 ` Andrey Ryabinin
2018-01-23 15:34   ` Andrey Konovalov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).