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: 153417 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp456162ljp; Tue, 11 Dec 2018 02:37:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WO6PZ/E2YyBvQz+r+twwgihITGbdHyi6l8HICoGrjsFps58Y2bgeP3zNtXfwsO55LN+RUI X-Received: by 2002:a17:902:aa82:: with SMTP id d2mr15558999plr.153.1544524663240; Tue, 11 Dec 2018 02:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544524663; cv=none; d=google.com; s=arc-20160816; b=RxT0yDDsw8rUDJTivoLnLNYjSurTgeiopzv4CYxAYDRBPoFRFYIJAMDyaTLNa1c2jp QvL03yg7ykdGggtmzOIEdNtevLIoC7q0WQ9L8xrgF3kVJlJWQOsLt30p5UMlVvMHWAcv zegyPa16BEGP4jjWR5++gskvvI+q27VOInDgywIkFxwIOhYiDVi0uGEVN9J8Oxu46uAn TT4VY2MS8YiIXjj9KItBUdcTK8Ta1ZYJ6hJs3nDXAgLSB9lpcq5On4x7JH4rEFpD3DrQ Dg/kjQeaANYw0yA4U5WAgf1pGjCaPfCpToPEWvkwRKj6Iau5VVcwzFCEe70RCX5bFthU 3LOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1ICbV7kzlI528WMoFmSsq88P2SQAOymySwYHXUg1CDQ=; b=frkt0luqhg3ng5SaXE8upCnU+i7l7aQlCMUIvXwSsu/6agNarJFw7Ef6PKt6SlSuAT aechho8pj4pvoCogVmteY9gtnB8SAZU4NAX0p/HfnU7pYfpL3YfdONt3Jdc8w2kAUg+b AZp9Q75vNPoZR0nnNSD+696bkSTIW7rZ6O1Y4g9j3S3dmQV21XFotXIJklHvxSPx9Ka/ 6m7fnsQ9emVVgn2zCdRXKN+X/9+KyDzm1zkEO/40XMO3s0OVeh7vkeIV9JrKpDuj0/DY +aBKCsbBebyRp6QCX111Kr4vjBL2nVH5+J6WgfRVdzLWLR+nfuP6McC38mArEU+ZVqWe CojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRUjNA5a; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a124si12827109pfb.263.2018.12.11.02.37.42; Tue, 11 Dec 2018 02:37:43 -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; dkim=pass header.i=@linaro.org header.s=google header.b=SRUjNA5a; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726378AbeLKKhk (ORCPT + 31 others); Tue, 11 Dec 2018 05:37:40 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46920 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbeLKKhk (ORCPT ); Tue, 11 Dec 2018 05:37:40 -0500 Received: by mail-lf1-f67.google.com with SMTP id f23so10348441lfc.13 for ; Tue, 11 Dec 2018 02:37:39 -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:mime-version :content-transfer-encoding; bh=1ICbV7kzlI528WMoFmSsq88P2SQAOymySwYHXUg1CDQ=; b=SRUjNA5ayLs39A+dNy1FwW2A9TYKJMLCQSAVEOrlcbxapbR3r6sdecoy7lCBTMnuBo VLuChpHXx0kU+L5oywp0oiPgFTfqkyunPZZ+OJlYwY0jYpGyjD4i554qhmtsVooRzI+p rDFJh+FFdfBu1RTThoDEY8fEtEVSyHafUUGXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1ICbV7kzlI528WMoFmSsq88P2SQAOymySwYHXUg1CDQ=; b=I/80UIrCV2BaAa2OWEWjFQW4e9WrkQ0wunZT/70xBd+gU4W/cpS0cUqsxhaa+HB+iw 9LrhutED5MhTxeDEk0jwhuEP+dCXBk3Na/pr8TR/Zi8P3kMDQF7S2qNV81sXE0P9UZfL eMgnVa8GOQYq4QFfUbGfP0jCMy8X3Jjc9wRVMXdHecbgPkMC45kvYAWPWQUWfEwPlbEQ gZvFR3MP65ZOY9K6uLyFVNuZQTFa9MkF3Q0H/cIY4MULxrRpH8h+KXEmKxOaD5xvbZHK 8Gxom337MzCLvC/qH4ppn1mKTcl3yn5foROpZbI3VnbYuW2obC/2FGMAXDKidjUGxY+E fZZw== X-Gm-Message-State: AA+aEWbdYvg3RGaBQmvoY74m8EYZlptJEXl07DUG04803Dzm+6BOa1Fk 4t9Fx6+vHjGEJoi7O4szlPEumqevYcwUaw== 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.19.2 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_); }