From patchwork Wed Jan 13 09:10:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12016199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDDF8C433DB for ; Wed, 13 Jan 2021 09:10:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42E922339D for ; Wed, 13 Jan 2021 09:10:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42E922339D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AB78A8D0029; Wed, 13 Jan 2021 04:10:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A42E58D0028; Wed, 13 Jan 2021 04:10:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9528D8D0029; Wed, 13 Jan 2021 04:10:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 7AFA48D0028 for ; Wed, 13 Jan 2021 04:10:34 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2ADBC9093 for ; Wed, 13 Jan 2021 09:10:34 +0000 (UTC) X-FDA: 77700181188.04.box71_5a0394d2751c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 10BDE8013B9B for ; Wed, 13 Jan 2021 09:10:34 +0000 (UTC) X-HE-Tag: box71_5a0394d2751c X-Filterd-Recvd-Size: 6144 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 09:10:33 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id k67so540231wmk.5 for ; Wed, 13 Jan 2021 01:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=pMSZunVusBFa2srMdPuW53fXoOwDSFeZUvebF05YN08=; b=KqcVQuSt5veMLDKRUt6O84+8i5TOyBjE63s6WSmXl/J4YumLAlIwZ23eKhOyqxW/3q 8bqGrmMvW5Q/4pMCfO1e7fNu70s8WqaN8QxeiigW9anD4S2JDmgeMQJz07q6wmEyDkuH 65zGNvke67SIqiNP4r7PU++ykEnr2L4izxhrvCtCZ6yiUhfawZL27Z5JSQFViP9CxNVe vcmn//jjMjzrJ090ONStuEcBcjrL/xItq8Nz9Po/V90Qk+HBNn1351e79qFAH0MbNJuq egktWW1LhHZC0VhDQFi4VBOqBWrSvMY4gE74L2oodKtXXpLmYFq/NFn1RGssEOuZcL3g NUhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pMSZunVusBFa2srMdPuW53fXoOwDSFeZUvebF05YN08=; b=Nf5VJ1UV1dW0Be+yg5gJcTaJw9ML3/9bqukv8jPqJ03vJwWYNJOpL4pOc8WRWN5Ona N3uprnXucM/OZGejNDyZl6DvAm027Sl6kmqnZ5vFRxEh6owSNF8ucXlYYFzjZH9qbhSv wevjaOaxfQMLlm+evFfHOZyEu571DULpzh65TDFeBTeCDZzBafu068N652VtjbyxDQgD L5A1pqCvNlLE2lCk06G8dbpR6vYLo2Te8c2OTrzviJCMv8ml0jGRItlZoNAYAbKUX6xe XPSXVecz5/UHMDL0J5gRctu6oFyWIABQbzm6Bhr7IFkHjdSl5oes0x8vgYIHsHXHg2tF 2dCQ== X-Gm-Message-State: AOAM531QwujUpDj6w9/gLH2YvOPX/Zj6AFQw1jrrxl2YRI52pL9Ip0KI 1mblC+tMkuUvnhW2P28CNzN1Zu3+Hqo= X-Google-Smtp-Source: ABdhPJyl97x324qrSmyL86FRY5AHU0rrfJxNTfZ/9wrifaxtWmqHQMY3hla8lUKjO9kJONB7SSj9OHLlJj4= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a7b:c157:: with SMTP id z23mr1186245wmi.35.1610529032166; Wed, 13 Jan 2021 01:10:32 -0800 (PST) Date: Wed, 13 Jan 2021 10:10:17 +0100 In-Reply-To: <20210113091017.1444780-1-glider@google.com> Message-Id: <20210113091017.1444780-5-glider@google.com> Mime-Version: 1.0 References: <20210113091017.1444780-1-glider@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 4/4] kasan: use error_report_start and error_report_end tracepoints From: Alexander Potapenko To: akpm@linux-foundation.org Cc: Alexander Potapenko , Marco Elver , Andrey Konovalov , Dmitry Vyukov , Ingo Molnar , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , linux-mm@kvack.org 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: Make it possible to trace KASAN error reporting (in particular, for compatibility with CONFIG_ERROR_REPORT_NOTIFY). Suggested-by: Marco Elver Cc: Andrew Morton Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Ingo Molnar Cc: Marco Elver Cc: Petr Mladek Cc: Steven Rostedt Cc: Sergey Senozhatsky Cc: linux-mm@kvack.org Signed-off-by: Alexander Potapenko --- mm/kasan/report.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index c0fb21797550..fd015dd5dd39 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -74,7 +75,7 @@ static void print_error_description(struct kasan_access_info *info) static DEFINE_SPINLOCK(report_lock); -static void start_report(unsigned long *flags) +static void start_report(unsigned long *flags, unsigned long addr) { /* * Make sure we don't end up in loop. @@ -82,10 +83,12 @@ static void start_report(unsigned long *flags) kasan_disable_current(); spin_lock_irqsave(&report_lock, *flags); pr_err("==================================================================\n"); + trace_error_report_start("kasan", addr); } -static void end_report(unsigned long *flags) +static void end_report(unsigned long *flags, unsigned long addr) { + trace_error_report_end("kasan", addr); pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); @@ -348,14 +351,14 @@ void kasan_report_invalid_free(void *object, unsigned long ip) kasan_update_kunit_status(current->kunit_test); #endif /* IS_ENABLED(CONFIG_KUNIT) */ - start_report(&flags); + start_report(&flags, (unsigned long)object); pr_err("BUG: KASAN: double-free or invalid-free in %pS\n", (void *)ip); print_tags(tag, object); pr_err("\n"); print_address_description(object, tag); pr_err("\n"); print_memory_metadata(object); - end_report(&flags); + end_report(&flags, (unsigned long)object); } static void __kasan_report(unsigned long addr, size_t size, bool is_write, @@ -385,7 +388,7 @@ static void __kasan_report(unsigned long addr, size_t size, bool is_write, info.is_write = is_write; info.ip = ip; - start_report(&flags); + start_report(&flags, addr); print_error_description(&info); if (addr_has_metadata(untagged_addr)) @@ -400,7 +403,7 @@ static void __kasan_report(unsigned long addr, size_t size, bool is_write, dump_stack(); } - end_report(&flags); + end_report(&flags, addr); } bool kasan_report(unsigned long addr, size_t size, bool is_write,