From patchwork Wed Aug 19 14:51:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 7038121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 77296C05AC for ; Wed, 19 Aug 2015 14:55:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C041207CD for ; Wed, 19 Aug 2015 14:55:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 622DE207C0 for ; Wed, 19 Aug 2015 14:55:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZS4iu-0004C2-KN; Wed, 19 Aug 2015 14:52:16 +0000 Received: from mail-la0-x230.google.com ([2a00:1450:4010:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZS4ii-0003Z0-70 for linux-arm-kernel@lists.infradead.org; Wed, 19 Aug 2015 14:52:05 +0000 Received: by lagz9 with SMTP id z9so4604794lag.3 for ; Wed, 19 Aug 2015 07:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=tbZJG9Ao3JhQlz6YwHr6XlbmzhKb4jumpifKgPhn2LA=; b=nqJJa7+IjTenrGTcGS7EwL92DzSIwKGw73+ESDO2dPLYC8hmuBLL762+MtXCQotII+ w1Z4MeUqtOoIV9W5VTcdeOiXYmGcSCnTy9Zoi3+eK57vXn91YasDSsFAKufXYJ6oCOic /HzowLBGFyD2RXH09N4WG8wn+2WQ0uHn5yd0IL+uw1KzffCSP41Tax2Emttq3ZA6lu6P Kqa4QBVsqmJxK5/wU7KB6jLQ1NWD9VuLlWpFjYuEQP8dKznR5b5QkCM3O8bL/JHB2Zv8 M0BadvY2PeDXmzAwuGx9s/rWJv5+HJXroaln9rY3IlXV70qpDgbmEmhVhNM33I58sZJb 2uGw== X-Received: by 10.152.37.67 with SMTP id w3mr11583138laj.123.1439995901397; Wed, 19 Aug 2015 07:51:41 -0700 (PDT) Received: from [10.30.25.228] (swsoft-msk-nat.sw.ru. [195.214.232.10]) by smtp.gmail.com with ESMTPSA id bb8sm271079lbc.47.2015.08.19.07.51.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 07:51:40 -0700 (PDT) Subject: Re: [PATCH v2 5/5] arm64: add KASan support To: Linus Walleij , Andrey Ryabinin References: <1431698344-28054-1-git-send-email-a.ryabinin@samsung.com> <1431698344-28054-6-git-send-email-a.ryabinin@samsung.com> <55AE56DB.4040607@samsung.com> <55AFD8D0.9020308@samsung.com> From: Andrey Ryabinin Message-ID: <55D497FC.9060506@gmail.com> Date: Wed, 19 Aug 2015 17:51:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150819_075204_466653_F42728A8 X-CRM114-Status: GOOD ( 24.05 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , "linux-mm@kvack.org" , Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , David Keitel , Alexander Potapenko , "linux-arm-kernel@lists.infradead.org" , Andrew Morton , Dmitry Vyukov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 08/19/2015 03:14 PM, Linus Walleij wrote: > On Wed, Jul 22, 2015 at 7:54 PM, Andrey Ryabinin wrote: > >> So here is updated version: >> git://github.com/aryabinin/linux.git kasan/arm_v0_1 >> >> The code is still ugly in some places and it probably have some bugs. >> Lightly tested on exynos 5410/5420. > > I compiled this for various ARM platforms and tested to boot. > I used GCC version 4.9.3 20150113 (prerelease) (Linaro). > > I get these compilation warnings no matter what I compile, > I chose to ignore them: > > WARNING: vmlinux.o(.meminit.text+0x2c): > Section mismatch in reference from the function kasan_pte_populate() > to the function > .init.text:kasan_alloc_block.constprop.7() > The function __meminit kasan_pte_populate() references > a function __init kasan_alloc_block.constprop.7(). > If kasan_alloc_block.constprop.7 is only used by kasan_pte_populate then > annotate kasan_alloc_block.constprop.7 with a matching annotation. > > WARNING: vmlinux.o(.meminit.text+0x98): > Section mismatch in reference from the function kasan_pmd_populate() > to the function > .init.text:kasan_alloc_block.constprop.7() > The function __meminit kasan_pmd_populate() references > a function __init kasan_alloc_block.constprop.7(). > If kasan_alloc_block.constprop.7 is only used by kasan_pmd_populate then > annotate kasan_alloc_block.constprop.7 with a matching annotation. > > These KASan outline tests run fine: > > kasan test: kmalloc_oob_right out-of-bounds to right > kasan test: kmalloc_oob_left out-of-bounds to left > kasan test: kmalloc_node_oob_right kmalloc_node(): out-of-bounds to right > kasan test: kmalloc_large_oob_rigth kmalloc large allocation: > out-of-bounds to right > kasan test: kmalloc_oob_krealloc_more out-of-bounds after krealloc more > kasan test: kmalloc_oob_krealloc_less out-of-bounds after krealloc less > kasan test: kmalloc_oob_16 kmalloc out-of-bounds for 16-bytes access > kasan test: kmalloc_oob_in_memset out-of-bounds in memset > kasan test: kmalloc_uaf use-after-free > kasan test: kmalloc_uaf_memset use-after-free in memset > kasan test: kmalloc_uaf2 use-after-free after another kmalloc > kasan test: kmem_cache_oob out-of-bounds in kmem_cache_alloc > > These two tests seems to not trigger KASan BUG()s, and seemse to > be like so on all hardware, so I guess it is this kind of test > that requires GCC 5.0: > > kasan test: kasan_stack_oob out-of-bounds on stack > kasan test: kasan_global_oob out-of-bounds global variable > > > Hardware test targets: > > Ux500 (ARMv7): > > On Ux500 I get a real slow boot (as exepected) and after > enabling the test cases produce KASan warnings > expectedly. > > MSM APQ8060 (ARMv7): > > Also a real slow boot and the expected KASan warnings when > running the tests. > > Integrator/AP (ARMv5): > > This one mounted with an ARMv5 ARM926 tile. It boots nicely > (but takes forever) with KASan and run all test cases (!) just like > for the other platforms but before reaching userspace this happens: > THREAD_SIZE hardcoded in act_mm macro. This hack should help: Tested-by: Linus Walleij --- > > I then tested on the Footbridge, another ARMv4 system, the oldest I have > SA110-based. This passes decompression and then you may *think* it hangs. > But it doesn't. It just takes a few minutes to boot with KASan > instrumentation, then all tests run fine also on this hardware. > The crash logs scroll by on the physical console. > > They keep scrolling forever however, and are still scrolling as I > write this. I suspect some real memory usage bugs to be causing it, > as it is exercising some ages old code that didn't see much scrutiny > in recent years. > I would suspect some kasan bug here. BTW, we probably need to introduce one-shot mode in kasan to prevent such report spam. I mean print only the first report and ignore the rest. The first report is the most important usually, next reports usually just noise. > > Yours, > Linus Walleij > diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index c671f34..b1765f2 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -32,6 +32,9 @@ .macro act_mm, rd bic \rd, sp, #8128 bic \rd, \rd, #63 +#ifdef CONFIG_KASAN + bic \rd, \rd, #8192 +#endif ldr \rd, [\rd, #TI_TASK] ldr \rd, [\rd, #TSK_ACTIVE_MM] .endm