From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932208AbdKOK1a convert rfc822-to-8bit (ORCPT ); Wed, 15 Nov 2017 05:27:30 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:14225 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932159AbdKOK1W (ORCPT ); Wed, 15 Nov 2017 05:27:22 -0500 From: "Liuwenliang (Abbott Liu)" To: Russell King - ARM Linux CC: "aryabinin@virtuozzo.com" , "afzal.mohd.ma@gmail.com" , "f.fainelli@gmail.com" , "labbott@redhat.com" , "kirill.shutemov@linux.intel.com" , "mhocko@suse.com" , "cdall@linaro.org" , "marc.zyngier@arm.com" , "catalin.marinas@arm.com" , "akpm@linux-foundation.org" , "mawilcox@microsoft.com" , "tglx@linutronix.de" , "thgarnie@google.com" , "keescook@chromium.org" , "arnd@arndb.de" , "vladimir.murzin@arm.com" , "tixy@linaro.org" , "ard.biesheuvel@linaro.org" , "robin.murphy@arm.com" , "mingo@kernel.org" , "glider@google.com" , "dvyukov@google.com" , "opendmb@gmail.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "kasan-dev@googlegroups.com" , "linux-mm@kvack.org" , Jiazhenghua , Dailei , Zengweilin , Heshaoliang 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] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: --- 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; } 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.