Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbdLDTSV (ORCPT ); Mon, 4 Dec 2017 14:18:21 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:40110 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751077AbdLDTRv (ORCPT ); Mon, 4 Dec 2017 14:17:51 -0500 X-Google-Smtp-Source: AGs4zMYtd+gBcBdhdclkgl23zJPOgag2ke4O5sVgY7JJGIDSnT5LIG7yaGMNfHMV60n9r8zJ3ZPquQ== From: Paul Lawrence To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kbuild@vger.kernel.org, Matthias Kaehlcke , Michael Davidson , Greg Hackmann , Paul Lawrence Subject: [PATCH v4 5/5] kasan: added functions for unpoisoning stack variables Date: Mon, 4 Dec 2017 11:17:35 -0800 Message-Id: <20171204191735.132544-6-paullawrence@google.com> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171204191735.132544-1-paullawrence@google.com> References: <20171204191735.132544-1-paullawrence@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1563 Lines: 46 From: Alexander Potapenko As a code-size optimization, LLVM builds since r279383 may bulk-manipulate the shadow region when (un)poisoning large memory blocks. This requires new callbacks that simply do an uninstrumented memset(). This fixes linking the Clang-built kernel when using KASAN. Signed-off-by: Alexander Potapenko [ghackmann@google.com: fix memset() parameters, and tweak commit message to describe new callbacks] Signed-off-by: Greg Hackmann Signed-off-by: Paul Lawrence --- mm/kasan/kasan.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index d96b36088b2f..8aaee42fcfab 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -770,6 +770,21 @@ void __asan_allocas_unpoison(const void *stack_top, const void *stack_bottom) } EXPORT_SYMBOL(__asan_allocas_unpoison); +/* Emitted by the compiler to [un]poison local variables. */ +#define DEFINE_ASAN_SET_SHADOW(byte) \ + void __asan_set_shadow_##byte(const void *addr, size_t size) \ + { \ + __memset((void *)addr, 0x##byte, size); \ + } \ + EXPORT_SYMBOL(__asan_set_shadow_##byte) + +DEFINE_ASAN_SET_SHADOW(00); +DEFINE_ASAN_SET_SHADOW(f1); +DEFINE_ASAN_SET_SHADOW(f2); +DEFINE_ASAN_SET_SHADOW(f3); +DEFINE_ASAN_SET_SHADOW(f5); +DEFINE_ASAN_SET_SHADOW(f8); + #ifdef CONFIG_MEMORY_HOTPLUG static int __meminit kasan_mem_notifier(struct notifier_block *nb, unsigned long action, void *data) -- 2.15.0.531.g2ccb3012c9-goog