From patchwork Wed Nov 15 10:19:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abbott Liu X-Patchwork-Id: 10059123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3506C60231 for ; Wed, 15 Nov 2017 10:27:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F70F29D98 for ; Wed, 15 Nov 2017 10:27:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2305C29E79; Wed, 15 Nov 2017 10:27:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7560B29D98 for ; Wed, 15 Nov 2017 10:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Pslz/MxCnIA8f0G7Yt3jYyiZlYoQNe4xQ5i1CbFf1sU=; b=Q4W6O+obZkg/Ct ZUXM1vj3cVu1xQWB53mEdRwADS7CEbA4YKaul8cThD0aM7mk+6xtdcZ/8tmNSp7lDKXJtZxz5Ujff vYE5tpuVzabyn4Aw7iD7UGg8vdcMTdnvEw5hWg89XYWa4OBa8535g359Gjvd0SJ2y0zX6GNIWa6D5 in77ytMBm5a4ogRyayn6/A+Rkz458qraGUVO1mur089Q82d7ihGzUlkYeuOWSpKp4GkIfg378XfgS mpPlwNhy6b0bYxZsWVu4FDVGSopePb7AWO1RPxxujaQOoLHaik0QvWuQWmR80SgN8fX34gCkTdfeS 2j/iWU7a4lk7ECyeNrMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eEuug-0000Cs-0G; Wed, 15 Nov 2017 10:27:22 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEuub-0000Bv-V9 for linux-arm-kernel@lists.infradead.org; Wed, 15 Nov 2017 10:27:20 +0000 Received: from 172.30.72.53 (EHLO DGGEMM403-HUB.china.huawei.com) ([172.30.72.53]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AZY83521; Wed, 15 Nov 2017 18:19:22 +0800 (CST) Received: from DGGEMM510-MBS.china.huawei.com ([169.254.11.85]) by DGGEMM403-HUB.china.huawei.com ([10.3.20.211]) with mapi id 14.03.0361.001; Wed, 15 Nov 2017 18:19:10 +0800 From: "Liuwenliang (Abbott Liu)" To: Russell King - ARM Linux Subject: Re: [PATCH 05/11] Disable kasan's instrumentation Thread-Topic: [PATCH 05/11] Disable kasan's instrumentation Thread-Index: AQHTQmojB64OgzmBjkqSXD92UdZT2KLqpdeAgCqyz9A= Date: Wed, 15 Nov 2017 10:19:09 +0000 Message-ID: References: <20171011082227.20546-1-liuwenliang@huawei.com> <20171011082227.20546-6-liuwenliang@huawei.com> <20171019124714.GZ20805@n2100.armlinux.org.uk> In-Reply-To: <20171019124714.GZ20805@n2100.armlinux.org.uk> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.57.90.243] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5A0C14AB.013C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.11.85, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 228eb5a4182bc64cc3f4a214e01dfc43 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171115_022718_503689_62308525 X-CRM114-Status: GOOD ( 10.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "tixy@linaro.org" , "mhocko@suse.com" , "catalin.marinas@arm.com" , "linux-mm@kvack.org" , "glider@google.com" , "afzal.mohd.ma@gmail.com" , "mingo@kernel.org" , "cdall@linaro.org" , "f.fainelli@gmail.com" , "mawilcox@microsoft.com" , "kasan-dev@googlegroups.com" , Dailei , "linux-arm-kernel@lists.infradead.org" , "aryabinin@virtuozzo.com" , "labbott@redhat.com" , "vladimir.murzin@arm.com" , "keescook@chromium.org" , "arnd@arndb.de" , "marc.zyngier@arm.com" , Zengweilin , "opendmb@gmail.com" , Heshaoliang , "tglx@linutronix.de" , "dvyukov@google.com" , "ard.biesheuvel@linaro.org" , "linux-kernel@vger.kernel.org" , Jiazhenghua , "akpm@linux-foundation.org" , "robin.murphy@arm.com" , "thgarnie@google.com" , "kirill.shutemov@linux.intel.com" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 19/10/17 20:47, Russell King - ARM Linux [mailto:linux@armlinux.org.uk] wrote: >On Wed, Oct 11, 2017 at 04:22:21PM +0800, Abbott Liu wrote: >> From: Andrey Ryabinin >> >> To avoid some build and runtime errors, compiler's instrumentation must >> be disabled for code not linked with kernel image. > >How does that explain the change to unwind.c ? Thanks for your review. Here is patch code: I change here because I don't think unwind_frame need to be check by kasan, and I have ever found the following error which rarely appares when remove the change of unwind.c. Here is the error log: ================================================================== BUG: KASAN: stack-out-of-bounds in unwind_frame+0x3e0/0x788 Read of size 4 at addr 868a3b20 by task swapper/0/1 CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc2+ #2 Hardware name: ARM-Versatile Express [<8011479c>] (unwind_backtrace) from [<8010f558>] (show_stack+0x10/0x14) [<8010f558>] (show_stack) from [<808fdca0>] (dump_stack+0x90/0xa4) [<808fdca0>] (dump_stack) from [<802b3808>] (print_address_description+0x4c/0x270) [<802b3808>] (print_address_description) from [<802b3ec4>] (kasan_report+0x218/0x300) [<802b3ec4>] (kasan_report) from [<801143f4>] (unwind_frame+0x3e0/0x788) [<801143f4>] (unwind_frame) from [<8010ebc4>] (walk_stackframe+0x2c/0x38) [<8010ebc4>] (walk_stackframe) from [<8010ee70>] (__save_stack_trace+0x160/0x164) [<8010ee70>] (__save_stack_trace) from [<802b342c>] (kasan_slab_free+0x84/0x158) [<802b342c>] (kasan_slab_free) from [<802b05dc>] (kmem_cache_free+0x58/0x1d4) [<802b05dc>] (kmem_cache_free) from [<801a6420>] (rcu_process_callbacks+0x600/0xe04) [<801a6420>] (rcu_process_callbacks) from [<801018e8>] (__do_softirq+0x1a0/0x4e0) [<801018e8>] (__do_softirq) from [<80131560>] (irq_exit+0xec/0x120) [<80131560>] (irq_exit) from [<8018d2a0>] (__handle_domain_irq+0x78/0xdc) [<8018d2a0>] (__handle_domain_irq) from [<80101700>] (gic_handle_irq+0x48/0x8c) [<80101700>] (gic_handle_irq) from [<80110690>] (__irq_svc+0x70/0x94) Exception stack(0x868a39f0 to 0x868a3a38) 39e0: 7fffffff 868a3b88 00000000 00000001 3a00: 868a3b84 7fffffff 868a3b88 6fd1474c 868a3ac0 868a0000 00000002 86898000 3a20: 00000001 868a3a40 8091b4d4 8091edb0 60000013 ffffffff [<80110690>] (__irq_svc) from [<8091edb0>] (schedule_timeout+0x0/0x3c4) [<8091edb0>] (schedule_timeout) from [<6fd14770>] (0x6fd14770) The buggy address belongs to the page: page:87fcc460 count:0 mapcount:0 mapping: (null) index:0x0 flags: 0x0() raw: 00000000 00000000 00000000 ffffffff 00000000 87fcc474 87fcc474 00000000 page dumped because: kasan: bad access detected Memory state around the buggy address: 868a3a00: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 868a3a80: 00 00 04 f4 f3 f3 f3 f3 00 00 00 00 00 00 00 00 >868a3b00: 00 00 00 00 f1 f1 f1 f1 04 f4 f4 f4 f2 f2 f2 f2 ^ 868a3b80: 00 00 00 00 00 04 f4 f4 f3 f3 f3 f3 00 00 00 00 868a3c00: 00 00 00 00 f1 f1 f1 f1 00 07 f4 f4 f3 f3 f3 f3 ================================================================== Disabling lock debugging due to kernel taint /* Before poping a register check whether it is feasible or not */ static int unwind_pop_register(struct unwind_ctrl_block *ctrl, unsigned long **vsp, unsigned int reg) { if (unlikely(ctrl->check_each_pop)) if (*vsp >= (unsigned long *)ctrl->sp_high) return -URC_FAILURE; // unwind_frame+0x3e0/0x788 is here ctrl->vrs[reg] = *(*vsp)++; return URC_OK; } > >Does this also disable the string macro changes? > >In any case, this should certainly precede patch 4, and very probably >patch 2. You are right. I will change it in net version. --- a/arch/arm/kernel/unwind.c +++ b/arch/arm/kernel/unwind.c @@ -249,7 +249,8 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl, if (*vsp >= (unsigned long *)ctrl->sp_high) return -URC_FAILURE; - ctrl->vrs[reg] = *(*vsp)++; + ctrl->vrs[reg] = READ_ONCE_NOCHECK(*(*vsp)); + (*vsp)++; return URC_OK; }