From patchwork Mon Feb 8 17:13:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 61423 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1571095lbl; Mon, 8 Feb 2016 09:35:48 -0800 (PST) X-Received: by 10.66.235.231 with SMTP id up7mr43522331pac.7.1454952947921; Mon, 08 Feb 2016 09:35:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hc1si38015168pac.16.2016.02.08.09.35.46; Mon, 08 Feb 2016 09:35:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbcBHRfp (ORCPT + 30 others); Mon, 8 Feb 2016 12:35:45 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36828 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbcBHRfn (ORCPT ); Mon, 8 Feb 2016 12:35:43 -0500 Received: by mail-pf0-f178.google.com with SMTP id e127so17377697pfe.3 for ; Mon, 08 Feb 2016 09:35:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=VH9dslVxqVRX6nicxb+eyMb+GOedqlzg1x5nTTmzgS8=; b=J6HV24yoO+AZgMLswzMZRgQJUy4TdP6w8/rUg5C6l93ymKnx3TEFn5GOdVLxzWP1FS G/wBOtuWEw8RgM3n75EOENTHuKJUU4qXcE5FcPfUsfugaswjdKB39iQ6lkCkWghyxE14 XtJCE60JU+lh1/qbrNcNy8f34Jfqe8Ej7Qe3M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VH9dslVxqVRX6nicxb+eyMb+GOedqlzg1x5nTTmzgS8=; b=a93YS4yVBGlSfg5Uy1k4lWY99mAdw23DUaQjrx4oZ1iEdBOhC3a9GkVOnWw52BA+5X kcx6Eqy1KrikRqDHj8gxX6ztItboKFCwX5O8fjQ8bLqyOMBgitca6rV7tdrnvS2XaUGc 99oEkgLMxMjGcx0jGy0/mxPDSvG1K0WWfNX4b39S00mxtMWnYavaRAdltqDAKl+acnL/ /+5U0nuS7khIqOm6oeAD67kxUYIQegZE8JhQrv8ySVNn3FikAJlyaYm6x9RXv5DztJBx M71ffz3FT8Qyi3cu0zPkGt5u+BMJCU8RnZ4mltx6r+3jxAfKQTUvgpNjFbJxxhVSOa/9 7Elg== X-Gm-Message-State: AG10YOQYwseJ0pUm7rNJyyDc2N8aMIsUN4pEV5hj1gMvqrD9vdnf5xnZGQs7GWqPJcz3+eOn X-Received: by 10.98.16.198 with SMTP id 67mr13968346pfq.21.1454952943300; Mon, 08 Feb 2016 09:35:43 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id ss5sm44915725pab.15.2016.02.08.09.35.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 09:35:42 -0800 (PST) From: Yang Shi To: aryabinin@virtuozzo.com, Will.Deacon@arm.com, Catalin.Marinas@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH v2] arm64: disable kasan when accessing frame->fp in unwind_frame Date: Mon, 8 Feb 2016 09:13:09 -0800 Message-Id: <1454951589-18238-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When boot arm64 kernel with KASAN enabled, the below error is reported by kasan: BUG: KASAN: out-of-bounds in unwind_frame+0xec/0x260 at addr ffffffc064d57ba0 Read of size 8 by task pidof/499 page:ffffffbdc39355c0 count:0 mapcount:0 mapping: (null) index:0x0 flags: 0x0() page dumped because: kasan: bad access detected CPU: 2 PID: 499 Comm: pidof Not tainted 4.5.0-rc1 #119 Hardware name: Freescale Layerscape 2085a RDB Board (DT) Call trace: [] dump_backtrace+0x0/0x290 [] show_stack+0x24/0x30 [] dump_stack+0x8c/0xd8 [] kasan_report_error+0x558/0x588 [] kasan_report+0x60/0x70 [] __asan_load8+0x60/0x78 [] unwind_frame+0xec/0x260 [] get_wchan+0x110/0x160 [] do_task_stat+0xb44/0xb68 [] proc_tgid_stat+0x40/0x50 [] proc_single_show+0x88/0xd8 [] seq_read+0x370/0x770 [] __vfs_read+0xc8/0x1d8 [] vfs_read+0x94/0x168 [] SyS_read+0xb8/0x128 [] el0_svc_naked+0x24/0x28 Memory state around the buggy address: ffffffc064d57a80: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 f4 f4 ffffffc064d57b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffffffc064d57b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ ffffffc064d57c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffffffc064d57c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Since the shadow byte pointed by the report is 0, so it may mean it is just hit oob in non-current task. So, disable the instrumentation to silence these warnings. Signed-off-by: Yang Shi --- v1 --> v2: * Replace kasan_disable{enable}_current to READ_ONCE_NOCHECK. * Cover the following statement too. arch/arm64/kernel/stacktrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.0.2 Acked-by: Will Deacon diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 4fad978..12a18cb 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -64,8 +64,8 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) return -EINVAL; frame->sp = fp + 0x10; - frame->fp = *(unsigned long *)(fp); - frame->pc = *(unsigned long *)(fp + 8); + frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); + frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); #ifdef CONFIG_FUNCTION_GRAPH_TRACER if (tsk && tsk->ret_stack &&