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: 8253281 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 A95D4BEEE5 for ; Mon, 8 Feb 2016 17:37:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3E0E202EC for ; Mon, 8 Feb 2016 17:37:28 +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 E967A202BE for ; Mon, 8 Feb 2016 17:37:27 +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 1aSpjN-0001jc-SM; Mon, 08 Feb 2016 17:36:09 +0000 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aSpjJ-0001RW-67 for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2016 17:36:06 +0000 Received: by mail-pf0-x22a.google.com with SMTP id e127so17377695pfe.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=RJ2RXxi7Brl+XI5gPgsbvkGSceTBbgD2xRwQI73fPflI3TA6186eJkqkKdGA7RTcD6 mnk9PvRSb0OcZGITbrcNGJ0Lgwp+yndDuLK3iV7fGayzCeWjmSlttD1kwNLiFoaCRP82 YQbM7tbgv2UWTl0Zo1K7UPnd303jFEvHNo9csY6N9Dr5fJKn1L78wQ4WOqCoXNpekE0J heWwlDqR/+opSDdVdqR9dEqVrT1agsaIIiPpusRJOSxfysBPSX444SDnPLfBiq5iPlMt 8bfjKT3GJwdoy+9k/mxSw1zTBydjoqX6HoaYFpWuI5l39Rb3tYWs4W51/K4dqNPNtpxc JuOQ== X-Gm-Message-State: AG10YOQo5jqwKG+Spo2lTHJodQEePbbN92EAIStUnoOwQhHAKDXw7NWTw48Beu4nK1EPqcUS 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160208_093605_564020_BEDBC255 X-CRM114-Status: GOOD ( 12.49 ) 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: yang.shi@linaro.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 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 Acked-by: Will Deacon Acked-by: Andrey Ryabinin --- 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(-) 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 &&