From patchwork Tue Dec 11 10:37:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 10723499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C85801869 for ; Tue, 11 Dec 2018 10:37:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B71CD299A3 for ; Tue, 11 Dec 2018 10:37:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB4542A0DC; Tue, 11 Dec 2018 10:37:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FDFB299A3 for ; Tue, 11 Dec 2018 10:37:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58B858E0081; Tue, 11 Dec 2018 05:37:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 512188E004D; Tue, 11 Dec 2018 05:37:41 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B3DB8E0081; Tue, 11 Dec 2018 05:37:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by kanga.kvack.org (Postfix) with ESMTP id C011C8E004D for ; Tue, 11 Dec 2018 05:37:40 -0500 (EST) Received: by mail-lj1-f198.google.com with SMTP id t7-v6so3703374ljg.9 for ; Tue, 11 Dec 2018 02:37:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:mime-version:content-transfer-encoding; bh=1ICbV7kzlI528WMoFmSsq88P2SQAOymySwYHXUg1CDQ=; b=hlORyEFLeJyATCWfn2PQ9zq7fwRo1QeGUgJo84z9+S3d3fNBLzZBePJ0pHSvDgkYAq hIiw8Hltwa0FspLjq9ToWyDSfWAhbZYn4k4bBlf/LT3UFQkAXeYNpt0ezzC0iAFxtWqO YBnKC3W112NnA+7RzDBv1iaGBBce41pTEWobANzc8Brz/0Roaf+phhfenozw96XVtbjZ +UIeFLrkoGmC0dwS6dxrqPvxPwJr4J3hMzkM8n4G6LuFP0aKEvsYK4r0yh4PDR4YsSn1 JerH4POniWKa4o20iwas2PAJpt7Eqj6/5X5iTFAQTsCyP+ONouAEojNcqn8pLJRBvicm S2jw== X-Gm-Message-State: AA+aEWZkn1hqT40BDl9vtW0GV4Eh8reko36NdWgqk/+xtzz0Vm1FfR4z 52tFNVsOVdHU3FJc3GXvqSUyZLHL+4NLsInDpPw4x8UsuuyLujAbJYGa3euhtExwTJGaAm1DYLe w64uWTF51KibdKubaPvUCK1oyF6uQVXNKBN5gYp9pC5aU3HvBe1zxJoTqmVNDzkPC4KkoZzVVa4 3nDVh9M2IVEA6MlJwsdN9sQOXb7DpecXM3JT51WT4mIqahQPPEo4jUP+tb7zjWwUX79evCTCRkM M6M2piOpMMCzY1pbB8QW+nuAXtt+CpejT4AL224n2hhxCT+vKba6kPckm/pmXxyq1DjJgaxyrHX pJlXstaWg4iXTjxhBGlI8EZVEe6BF3ZpefKUrai/tdK8kc2RfBlv7hAMSgNoH7zc8xWHhVWxzIP N X-Received: by 2002:a19:1019:: with SMTP id f25mr8782989lfi.54.1544524659893; Tue, 11 Dec 2018 02:37:39 -0800 (PST) X-Received: by 2002:a19:1019:: with SMTP id f25mr8782950lfi.54.1544524658802; Tue, 11 Dec 2018 02:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544524658; cv=none; d=google.com; s=arc-20160816; b=O+ElMzuDO2DDs3SBQuOKv4CbnKj3Yfj5RKm8cSkVESYlfnqbVBRlnHX7GaSuMJ/e+S tRpCwPWjm6S7RPesXc9C9wKg4I8epucEOQtWR0FNvg8fwGxVC5jdQaDut/Yx5Nov5q9s hmCNQ6WnNI9isGq0eUk4SljRh4mJsvgzk74lYT/WzbFk7D6NtpttvW5dCnAUV09AMQvX qN+upEBz7h+wQCo+p0CDaaVht6Mt8PVjFawan5lF3KeF0C6ncdRvDwqwPtgrBTRoIOi+ 0FLs4kDblaHYihu0kNlJ1M3YOQ2B/SEQoZCuVLrUtvxemXUDc34ZlWRUqEFGs9kEWu89 7AKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=1ICbV7kzlI528WMoFmSsq88P2SQAOymySwYHXUg1CDQ=; b=JEzZTZiWhowHMN5xI+lxSd107nuoHJ1BLrDFNCDy+7nZ6UXYhjCWoDVjb5rCTCbJ4R PKe2hy4in1wg24D5BwHs1NomVGGmBzzkW68LzxLeA1UkEuEJMivtXMfzc0zTdv8TvD31 575JOhdip7KRvNUAcqTdHsS1JJQOKjg8hNI+WMhTAJ/2ULe1dK1+xOGNBTwns2zASGUx rlvwJKeLqxTN8bBOp6/nxqURKRPEmUIrT89VGeHWgU3+d4RiOqCjvj5O6Io43oxz4c+A prrwLZ/OaeDUc8GO1nAkHdZ7ucEJBDwYazvVkDyfkkQfzDgDQ/k6GpwruvjJ/1b+2F7y 0g3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRUjNA5a; spf=pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=anders.roxell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 129sor3613013lfl.19.2018.12.11.02.37.38 for (Google Transport Security); Tue, 11 Dec 2018 02:37:38 -0800 (PST) Received-SPF: pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRUjNA5a; spf=pass (google.com: domain of anders.roxell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=anders.roxell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1ICbV7kzlI528WMoFmSsq88P2SQAOymySwYHXUg1CDQ=; b=SRUjNA5ayLs39A+dNy1FwW2A9TYKJMLCQSAVEOrlcbxapbR3r6sdecoy7lCBTMnuBo VLuChpHXx0kU+L5oywp0oiPgFTfqkyunPZZ+OJlYwY0jYpGyjD4i554qhmtsVooRzI+p rDFJh+FFdfBu1RTThoDEY8fEtEVSyHafUUGXI= X-Google-Smtp-Source: AFSGD/VlcWcAxL+yp0Kfdb5nQpSHYRrdlX/G1braOl+Y1F7wApKq13FW6QHPjryrkLvZHWxGF4oNzQ== X-Received: by 2002:a19:4e59:: with SMTP id c86mr9471367lfb.132.1544524658206; Tue, 11 Dec 2018 02:37:38 -0800 (PST) Received: from localhost (c-732171d5.07-21-73746f28.bbcust.telenor.se. [213.113.33.115]) by smtp.gmail.com with ESMTPSA id y81-v6sm2659583lje.30.2018.12.11.02.37.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Dec 2018 02:37:37 -0800 (PST) From: Anders Roxell To: aryabinin@virtuozzo.com Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, Anders Roxell Subject: [PATCH] kasan: mark kasan_check_(read|write) as 'notrace' Date: Tue, 11 Dec 2018 11:37:33 +0100 Message-Id: <20181211103733.22284-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When option CONFIG_KASAN is enabled toghether with ftrace, function ftrace_graph_caller() gets in to a recursion, via functions kasan_check_read() and kasan_check_write(). Breakpoint 2, ftrace_graph_caller () at ../arch/arm64/kernel/entry-ftrace.S:179 179 mcount_get_pc x0 // function's pc (gdb) bt #0 ftrace_graph_caller () at ../arch/arm64/kernel/entry-ftrace.S:179 #1 0xffffff90101406c8 in ftrace_caller () at ../arch/arm64/kernel/entry-ftrace.S:151 #2 0xffffff90106fd084 in kasan_check_write (p=0xffffffc06c170878, size=4) at ../mm/kasan/common.c:105 #3 0xffffff90104a2464 in atomic_add_return (v=, i=) at ./include/generated/atomic-instrumented.h:71 #4 atomic_inc_return (v=) at ./include/generated/atomic-fallback.h:284 #5 trace_graph_entry (trace=0xffffffc03f5ff380) at ../kernel/trace/trace_functions_graph.c:441 #6 0xffffff9010481774 in trace_graph_entry_watchdog (trace=) at ../kernel/trace/trace_selftest.c:741 #7 0xffffff90104a185c in function_graph_enter (ret=, func=, frame_pointer=18446743799894897728, retp=) at ../kernel/trace/trace_functions_graph.c:196 #8 0xffffff9010140628 in prepare_ftrace_return (self_addr=18446743592948977792, parent=0xffffffc03f5ff418, frame_pointer=18446743799894897728) at ../arch/arm64/kernel/ftrace.c:231 #9 0xffffff90101406f4 in ftrace_graph_caller () at ../arch/arm64/kernel/entry-ftrace.S:182 Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) Rework so that kasan_check_read() and kasan_check_write() is marked with 'notrace'. Signed-off-by: Anders Roxell --- mm/kasan/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 03d5d1374ca7..71507d15712b 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -95,13 +95,13 @@ void kasan_disable_current(void) current->kasan_depth--; } -void kasan_check_read(const volatile void *p, unsigned int size) +void notrace kasan_check_read(const volatile void *p, unsigned int size) { check_memory_region((unsigned long)p, size, false, _RET_IP_); } EXPORT_SYMBOL(kasan_check_read); -void kasan_check_write(const volatile void *p, unsigned int size) +void notrace kasan_check_write(const volatile void *p, unsigned int size) { check_memory_region((unsigned long)p, size, true, _RET_IP_); }