From patchwork Fri Feb 5 23:04:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 61357 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp251293lbl; Fri, 5 Feb 2016 15:27:14 -0800 (PST) X-Received: by 10.98.16.86 with SMTP id y83mr23531277pfi.45.1454714834642; Fri, 05 Feb 2016 15:27:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si26792716pas.108.2016.02.05.15.27.14; Fri, 05 Feb 2016 15:27:14 -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 S1750928AbcBEX1M (ORCPT + 30 others); Fri, 5 Feb 2016 18:27:12 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:33950 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750754AbcBEX1L (ORCPT ); Fri, 5 Feb 2016 18:27:11 -0500 Received: by mail-pa0-f42.google.com with SMTP id uo6so42117163pac.1 for ; Fri, 05 Feb 2016 15:27:10 -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=lZwpdLsOsjUaf5wYCskl9XBveq/qYrCSnCQmSQLj3qA=; b=gEst+Li/I8KY6CjcNRrCN4hH/CtXNNvgzeXPsdFHK7O9Qw0n37k2TJCjyta5GYalXd QnyiQHrwAcxdlsXkTIWsnbHtDIFnMZsTiyJFQi5vx3XWsnEQNmfV6QbUzIrZ0KKBmAor 4Yp1p6SEbjdMowjAt5veSzve7SbNOl9f80sYY= 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=lZwpdLsOsjUaf5wYCskl9XBveq/qYrCSnCQmSQLj3qA=; b=IN2Lkzhszmgo3gpNgCc+EGkzsY1JQcLxfsX/ESh0E7+JKwgMBenAlv4muJ9aitIvGI mVRhSXdT9EMGMTsjgLIWNZfgii3+ai5YUt8ydEUOmHJysdxpf2B4IHzq/IVWoEG+0dbi dEN69cqM3K6bUWRANgRyV97zyVoEPGNv1qV9b/kBWytKa/pp5l2iZLoKFB5flFVRxVHU 1iFaf7jUi97MxMuY3shM5ClhX4fjwYrlqLKv3BiBaEKjyD/EKE3E5HKf6kmb4p+VUqlC bp/toWySoMovqgzGepqdq0jhn+skjbDCwG5dKukAe6KQChXxaOjUFWtxYnNVwKjqs8xG hQng== X-Gm-Message-State: AG10YOR81pIsN0KGW0Bo7c37gsAdmYoLPy31vIWYIcc8bxceSsv6uK4IVAjgJWO0HGgOEO4C X-Received: by 10.66.235.231 with SMTP id up7mr23448987pac.7.1454714830153; Fri, 05 Feb 2016 15:27:10 -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 h89sm22464632pfj.52.2016.02.05.15.27.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2016 15:27:09 -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] arm64: disable kasan when accessing frame->fp in unwind_frame Date: Fri, 5 Feb 2016 15:04:47 -0800 Message-Id: <1454713487-5239-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 here. Signed-off-by: Yang Shi --- arch/arm64/kernel/stacktrace.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.0.2 diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 4fad978..88278c2 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -64,7 +65,9 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) return -EINVAL; frame->sp = fp + 0x10; + kasan_disable_current(); frame->fp = *(unsigned long *)(fp); + kasan_enable_current(); frame->pc = *(unsigned long *)(fp + 8); #ifdef CONFIG_FUNCTION_GRAPH_TRACER