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: 8240301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6CE39F37A for ; Fri, 5 Feb 2016 23:30:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 050A12015E for ; Fri, 5 Feb 2016 23:30:06 +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 31D5720155 for ; Fri, 5 Feb 2016 23:30:05 +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 1aRpmp-0006PR-Se; Fri, 05 Feb 2016 23:27:35 +0000 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRpmk-00068v-Ru for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2016 23:27:31 +0000 Received: by mail-pa0-x235.google.com with SMTP id ho8so41401196pac.2 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=ap8paa+a7DXInU9Xhl25Bdi7082qpm14UsfxlFWOlfhyThBQ0fU8Tvrz0CodBDlygj vRf8XqM4hgrwJmCZWfbOjPQdXiJP8XBxNlP/VxzG5Q95iY8TS2dHexINsQRFhEYereHn nfURKEDswc6zxCv6PhtREptdGw8bQYtOKM10NRCTiNEBlhyX7dwNlbV6+h+TH10/9bUi pWQ5VD1/zoGZKN2mD1VxZmgo1ZQOJ14fxUIH3hGlUUGQVi8ivfs7wcwjihTyYRSXvTO9 vfNaBloat+L2H57at+lHndFpUAgMMa6/SlzKyDnUeskzXtpb5e3dC1LYAXDn47e2Ci84 AYRw== X-Gm-Message-State: AG10YOQNOjEDzxI4M8fGySH8FRExQe0GW1EC1ySZC/pySP/gL1iWiYlkqQj5V2rA9iXPG1hv 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160205_152730_957760_405AFEC5 X-CRM114-Status: GOOD ( 10.12 ) 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 here. Signed-off-by: Yang Shi --- arch/arm64/kernel/stacktrace.c | 3 +++ 1 file changed, 3 insertions(+) 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