From patchwork Wed Jan 13 09:16:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12016209 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 CD83AC433E0 for ; Wed, 13 Jan 2021 09:17:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5530E233E2 for ; Wed, 13 Jan 2021 09:17:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5530E233E2 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 A9E5C8D0024; Wed, 13 Jan 2021 04:17:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4DF58D0019; Wed, 13 Jan 2021 04:17:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 964A28D0024; Wed, 13 Jan 2021 04:17:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 7F7758D0019 for ; Wed, 13 Jan 2021 04:17:05 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4CCECFB49 for ; Wed, 13 Jan 2021 09:17:05 +0000 (UTC) X-FDA: 77700197610.27.spot43_090c0fe2751c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 32DFC3D668 for ; Wed, 13 Jan 2021 09:17:05 +0000 (UTC) X-HE-Tag: spot43_090c0fe2751c X-Filterd-Recvd-Size: 7396 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 09:17:04 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id u3so634331wri.19 for ; Wed, 13 Jan 2021 01:17:04 -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=fSzBeKXP0Nh8klQwaoWnqoqW21r9BnvxbYgVEskeqWs=; b=UaLVElNBweVx72KvGpJgtpmWaCqmMmu6qvX+GlVI4VwcXD9u7ZBdmq7KJ6cKg7U+Se JbSEXj6esp011RsM6SrrBM/Z37oVQzITPDyuGcM05To+x0oATeQSN/7TIcrNixBuGo6Z QMG9aV8Vyk/EBGIQ9hxYPGCkJ7ti7qMr8ycqGDIKhGTT3PijEJaVERzOOwwEjccGtlQO USXR9lOI7yFayytiGWhg8+YPf+a/C17wiLcGFg7PfTFnIbOHKXvexYfXKt1+gOJBpCPZ t6OQniYCIcAhdOsPlGNIwY8dq2Deip0KtYJL0aeRNRHUVD/GnqLQnF49xBSjeAVhI8wE dhQA== 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=fSzBeKXP0Nh8klQwaoWnqoqW21r9BnvxbYgVEskeqWs=; b=bE5MQ7zx5wuB80dan5+Ty6vHwCytzqFs7ZhHrbu7EjYVYNVNNulz21GPq9lVcr3vNg BO6RgAdijZBV2zKVjY5BCEZridu53iQCZlsVLldSnvWaLS42WySakjbcrR//L0hHKJWM Kkm8EYN5KReDseG7SZP6QgWPLItlhyMagwIL1ot+qfRq5GDwDbgUyyiNBMEaSMs90hkS kJR4qmroaxPjPDCpTlSso6nB3vV4qSOmoSWr6eVm6pUXf3z7esjmPcz7mnItNNoMEEX2 ei+u8AJJGc4sOUt4Vo82wv+E1C7doCpb/hmEc8FA5KRH2PYr5AeCkMBHG4ZMFKsQOABI JSAA== X-Gm-Message-State: AOAM532TCHmkVU9Q2Ww6urwc/6VuYQlfFMNanruaqOpWEKT/U/Eo8KuC /EpjCxuiLxW7u/e48z+n8f6CqO2gc6U= X-Google-Smtp-Source: ABdhPJw/KuNFkxyyB1KSEKTrztCAmdyBZRpgcGYjCMfnpeJSM7Q7rkVPtp4ci0zlvY3xOwMcFyI1RGqupKA= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a1c:6484:: with SMTP id y126mr1222870wmb.76.1610529423513; Wed, 13 Jan 2021 01:17:03 -0800 (PST) Date: Wed, 13 Jan 2021 10:16:54 +0100 In-Reply-To: <20210113091657.1456216-1-glider@google.com> Message-Id: <20210113091657.1456216-2-glider@google.com> Mime-Version: 1.0 References: <20210113091657.1456216-1-glider@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 1/4] tracing: add error_report trace points From: Alexander Potapenko To: akpm@linux-foundation.org, linux-kernel@vger.kernel.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: Introduce error_report_start and error_report_end tracepoints. Those can be used in debugging tools like KASAN, KFENCE, etc. to provide extensions to the error reporting mechanisms (e.g. allow tests hook into error reporting, ease error report collection from production kernels). Another benefit would be making use of ftrace for debugging or benchmarking the tools themselves. 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 --- include/trace/events/error_report.h | 51 +++++++++++++++++++++++++++++ kernel/trace/Makefile | 1 + kernel/trace/error_report-traces.c | 11 +++++++ 3 files changed, 63 insertions(+) create mode 100644 include/trace/events/error_report.h create mode 100644 kernel/trace/error_report-traces.c diff --git a/include/trace/events/error_report.h b/include/trace/events/error_report.h new file mode 100644 index 000000000000..bae0129031f0 --- /dev/null +++ b/include/trace/events/error_report.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM error_report + +#if !defined(_TRACE_ERROR_REPORT_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_ERROR_REPORT_H + +#include + +DECLARE_EVENT_CLASS(error_report_template, + TP_PROTO(const char *error_detector, unsigned long id), + TP_ARGS(error_detector, id), + TP_STRUCT__entry(__field(const char *, error_detector) + __field(unsigned long, id)), + TP_fast_assign(__entry->error_detector = error_detector; + __entry->id = id;), + TP_printk("[%s] %lx", __entry->error_detector, + __entry->id)); + +/** + * error_report_start - called before printing the error report + * @error_detector: short string describing the error detection tool + * @id: pseudo-unique descriptor that can help distinguish reports + * from one another. Depending on the tool, good examples + * could be: memory access address, call site, allocation + * site, etc. + * + * This event occurs right before a debugging tool starts printing the error + * report. + */ +DEFINE_EVENT(error_report_template, error_report_start, + TP_PROTO(const char *error_detector, unsigned long id), + TP_ARGS(error_detector, id)); + +/** + * error_report_end - called after printing the error report + * @error_detector: short string describing the error detection tool + * @id: pseudo-unique descriptor, matches that passed to + * error_report_start + * + * This event occurs right after a debugging tool finishes printing the error + * report. + */ +DEFINE_EVENT(error_report_template, error_report_end, + TP_PROTO(const char *error_detector, unsigned long id), + TP_ARGS(error_detector, id)); + +#endif /* _TRACE_ERROR_REPORT_H */ + +/* This part must be outside protection */ +#include diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 7e44cea89fdc..b28d3e5013cd 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -81,6 +81,7 @@ obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o +obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o ifeq ($(CONFIG_PM),y) obj-$(CONFIG_TRACEPOINTS) += rpm-traces.o diff --git a/kernel/trace/error_report-traces.c b/kernel/trace/error_report-traces.c new file mode 100644 index 000000000000..80960c52c705 --- /dev/null +++ b/kernel/trace/error_report-traces.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Error reporting trace points + */ + +#define CREATE_TRACE_POINTS +#include + +EXPORT_TRACEPOINT_SYMBOL_GPL(error_report_start); +EXPORT_TRACEPOINT_SYMBOL_GPL(error_report_end); + From patchwork Wed Jan 13 09:16:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12016211 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 B3B0BC433E6 for ; Wed, 13 Jan 2021 09:17:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04414233E2 for ; Wed, 13 Jan 2021 09:17:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04414233E2 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 742928D0028; Wed, 13 Jan 2021 04:17:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F9F48D0026; Wed, 13 Jan 2021 04:17:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 571378D0028; Wed, 13 Jan 2021 04:17:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 31D2D8D0026 for ; Wed, 13 Jan 2021 04:17:07 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EDBCC181AEF23 for ; Wed, 13 Jan 2021 09:17:06 +0000 (UTC) X-FDA: 77700197652.12.start26_04110ee2751c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id CBDE6180812EB for ; Wed, 13 Jan 2021 09:17:06 +0000 (UTC) X-HE-Tag: start26_04110ee2751c X-Filterd-Recvd-Size: 15366 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 09:17:06 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id x19so965082qvv.16 for ; Wed, 13 Jan 2021 01:17:06 -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=Mr/4JAPGFDkrDog5eCdPJZ3B6Plu19ZsSHa5ZA4i3EU=; b=r3weQHC0gtQrR0xGzNuA/hpnNQ/b8L1qFXMEPJhDztRBSfpCKKg8aqzcD2gvweG1xX bhVRRJL2eW60Li5pcqm9iaDD+WCC0IOsj7yGFCIPvuZvnptjKFf+/cw/etzVChpW+Ppr KRi41FoNV+41QLJDpbhuvn+ysEd1uNkeETh7AfbkXK77Ge3qSG14jT1JdBCHqu0xdVBu p8xtQdk6SPVtaiUAznoc1udU3l13m64FFZE5iYXBv89QQ6alMEf/8pcAuFRYxI/JeXYu 1fMKScIO7XwTzpsBSJslcdUJisVtHrkRniSvnOyXIUUgTrD+gFNoEkXfvI8GKOBBdjH+ MtHQ== 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=Mr/4JAPGFDkrDog5eCdPJZ3B6Plu19ZsSHa5ZA4i3EU=; b=ZtGy7OAnPq7q0h3X4/KYcTM1H5n+iiOhOcy/1/nO4nzPAU+ZbMbU5yu6xCr1SfeSlf ZEsmJ9sg/k5sAS1q7DCTuQFny6WrducD+9fwenyrGYI7XoNNFPXbGPF7PcwcPAd/TStB 6FdjzWQ0QznMXYw+2COIsfGj2MBaEvVa0NJFQEjqe+obl07ICnA0pHx82RcGQcI8RieF qtfDZclK9M5QJvOJZUrOrD1Phtj1/G8fnmb4TMi9JKoKetDhSdTfNqUwjcns171wo6u5 fzWYv2ewpmEdGmV7DSsnKUP9k/GS2XgNWxKuQOWxEt0VN2yVF4b/yleA2uZQxisUixJT htoA== X-Gm-Message-State: AOAM5322prHSy7kHB/8Iv4X86Xwc0A9uaSZOpv29dZEtCaw9Gu/JTkiB d/NgGhf3C7Lo0u3573DPMNGVIr40zlc= X-Google-Smtp-Source: ABdhPJzkORoQhiEB0AhKANZENrXtmJ5BzqQCHLq2xMZfujpA1ICxDYm2aFPTBBNZhxVx2vGpi346FOWwJrs= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a0c:c583:: with SMTP id a3mr1230726qvj.15.1610529425627; Wed, 13 Jan 2021 01:17:05 -0800 (PST) Date: Wed, 13 Jan 2021 10:16:55 +0100 In-Reply-To: <20210113091657.1456216-1-glider@google.com> Message-Id: <20210113091657.1456216-3-glider@google.com> Mime-Version: 1.0 References: <20210113091657.1456216-1-glider@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 2/4] lib: add error_report_notify to collect debugging tools' reports From: Alexander Potapenko To: akpm@linux-foundation.org, linux-kernel@vger.kernel.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: With the introduction of various production error-detection tools, such as MTE-based KASAN and KFENCE, the need arises to efficiently notify the userspace OS components about kernel errors. Currently, no facility exists to notify userspace about a kernel error from such bug-detection tools. The problem is obviously not restricted to the above bug detection tools, and applies to any error reporting mechanism that does not panic the kernel; this series, however, will only add support for KASAN and KFENCE reporting. All such error reports appear in the kernel log. But, when such errors occur, userspace would normally need to read the entire kernel log and parse the relevant errors. This is error prone and inefficient, as userspace needs to continuously monitor the kernel log for error messages. On certain devices, this is unfortunately not acceptable. Therefore, we need to revisit how reports are propagated to userspace. The library added, error_report_notify (CONFIG_ERROR_REPORT_NOTIFY), solves the above by using the error_report_start/error_report_end tracing events and exposing the last report and the total report count to the userspace via /sys/kernel/error_report/last_report and /sys/kernel/error_report/report_count. Userspace apps can call poll(POLLPRI) on those files to get notified about the new reports without having to watch dmesg in a loop. 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 --- lib/Kconfig.debug | 14 ++ lib/Makefile | 2 + lib/error_report_notify.c | 278 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 lib/error_report_notify.c diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 4b8f9e018f0f..c3f4aae9f19e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -209,6 +209,20 @@ config DEBUG_BUGVERBOSE of the BUG call as well as the EIP and oops trace. This aids debugging but costs about 70-100K of memory. +config ERROR_REPORT_NOTIFY + bool "Expose memory error reports to the userspace" + depends on TRACING + help + When enabled, captures error reports from debugging tools (such as + KFENCE or KASAN) using console tracing, and exposes reports in + /sys/kernel/error_report/: the file last_report contains the last + report (with maximum report length of PAGE_SIZE), and report_count, + the total report count. + + Userspace programs can call poll(POLLPRI) on those files to get + notified about the new reports without having to watch dmesg in a + loop. + endmenu # "printk and dmesg options" menu "Compile-time checks and compiler options" diff --git a/lib/Makefile b/lib/Makefile index afeff05fa8c5..96ed8bc0cc5b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -240,6 +240,8 @@ obj-$(CONFIG_CPU_RMAP) += cpu_rmap.o obj-$(CONFIG_DQL) += dynamic_queue_limits.o +obj-$(CONFIG_ERROR_REPORT_NOTIFY) += error_report_notify.o + obj-$(CONFIG_GLOB) += glob.o obj-$(CONFIG_GLOB_SELFTEST) += globtest.o diff --git a/lib/error_report_notify.c b/lib/error_report_notify.c new file mode 100644 index 000000000000..b0633f36ce6d --- /dev/null +++ b/lib/error_report_notify.c @@ -0,0 +1,278 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Userspace notification interface for debugging tools. + * + * Provide two sysfs files: + * - /sys/kernel/error_report/last_report + * - /sys/kernel/error_report/report_count + * that contain the last debugging tool report (taken from dmesg, delimited by + * the error_report_start/error_report_end tracing events) and the total report + * count. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct kobject *error_report_kobj; + +/* sysfs files are capped at PAGE_SIZE. */ +#define BUF_SIZE PAGE_SIZE +/* Two buffers to store the finished report and the report being recorded. */ +static char report_buffer[2][BUF_SIZE]; +/* + * Total report count. Also serves as a latch for report_buffer: + * report_buffer[num_reports % 2] is the currently available report, + * report_buffer[(num_reports + 1) % 2] is the report being recorded. + */ +static atomic_t num_reports; + +/* + * PID of the task currently recording the report, as returned by + * get_encoded_pid(), or -1. Used as a writer lock for report_buffer. + * A regular spinlock couldn't be used here, as probe_console() can be called + * from any thread, and it needs to know whether that thread is holding the + * lock. + */ +static atomic_t current_pid = ATOMIC_INIT(-1); + +static size_t current_pos; +static bool truncated; +static const char TRUNC_MSG[] = "\n"; + +static struct delayed_work reporting_done; + +static void error_report_notify(struct work_struct *work) +{ + sysfs_notify(error_report_kobj, NULL, "last_report"); + sysfs_notify(error_report_kobj, NULL, "report_count"); +} +static DECLARE_DELAYED_WORK(reporting_done, error_report_notify); + +/* + * Return the current PID combined together with in_task(). This lets us + * distinguish between normal task context and IRQ context. + */ +static int get_encoded_pid(void) +{ + return (current->pid << 1) | (!!in_task()); +} + +/* + * Trace hook for the error_report_start event. In an unlikely case of another + * task already printing a report bail out, otherwise save the current pid + * together with in_task() return value. + * + * Because reporting code can be called from low-level routines (e.g. locking + * primitives or allocator guts), report recording is implemented using a + * seqlock lock-free algorithm. + */ +static void probe_report_start(void *ignore, const char *tool_name, + unsigned long id) +{ + /* + * Acquire the writer lock. Any racing probe_report_start will not + * record anything. Pairs with the release in probe_report_end(). + */ + if (atomic_cmpxchg_acquire(¤t_pid, -1, get_encoded_pid()) != -1) + return; + current_pos = 0; + truncated = false; +} + +/* + * Trace hook for the error_report_end event. If an event from the mismatching + * error_report_start is received, it is ignored. Otherwise, null-terminate the + * buffer, increase the report count (effectively releasing the report to + * last_report_show() and schedule a notification about a new report. + */ +static void probe_report_end(void *ignore, const char *tool_name, + unsigned long id) +{ + pid_t pid = atomic_read(¤t_pid); + int idx; + + if (pid != get_encoded_pid()) + return; + + idx = (atomic_read(&num_reports) + 1) % 2; + if (current_pos == BUF_SIZE) + report_buffer[idx][current_pos - 1] = 0; + else + report_buffer[idx][current_pos] = 0; + + /* Pairs with acquire in last_report_show(). */ + atomic_inc_return_release(&num_reports); + schedule_delayed_work(&reporting_done, 0); + /* + * Release the writer lock. Pairs with the acquire in + * probe_report_start(). + */ + atomic_set_release(¤t_pid, -1); +} + +/* + * Skip one or two leading pair of brackets containing the log timestamp and + * the task/CPU ID, plus the leading space, from the report line, e.g.: + * [ 0.698431][ T7] BUG: KFENCE: use-after-free ... + * becomes: + * BUG: KFENCE: use-after-free ... + * + * Report size is only 4K, and this boilerplate can easily account for half of + * that amount. + */ +static void skip_extra_info(const char **buf, size_t *len) +{ + int num_brackets = IS_ENABLED(CONFIG_PRINTK_TIME) + + IS_ENABLED(CONFIG_PRINTK_CALLER); + const char *found; + + if (!buf || !len) + return; + + while (num_brackets--) { + if (!*len || *buf[0] != '[') + return; + found = strnchr(*buf, *len, ']'); + if (!found) + return; + *len -= found - *buf + 1; + *buf = found + 1; + } + if (*len && *buf[0] == ' ') { + ++*buf; + --*len; + } +} + +/* + * Trace hook for the console event. If a line comes from a task/CPU that did + * not send the error_report_start event, that line is ignored. Otherwise, it + * is stored in the report_buffer[(num_reports + 1) % 2]. + * + * To save space, the leading timestamps and (when enabled) CPU/task info is + * stripped away. The buffer may contain newlines, so this procedure is + * repeated for every line. + */ +static void probe_console(void *ignore, const char *buf, size_t len) +{ + int pid = atomic_read(¤t_pid); + size_t to_copy, cur_len; + char *newline; + int idx; + + if (pid != get_encoded_pid() || truncated) + return; + + idx = (atomic_read(&num_reports) + 1) % 2; + while (len) { + newline = strnchr(buf, len, '\n'); + if (newline) + cur_len = newline - buf + 1; + else + cur_len = len; + /* Adjust len now, because skip_extra_info() may change cur_len. */ + len -= cur_len; + skip_extra_info(&buf, &cur_len); + to_copy = min(cur_len, BUF_SIZE - current_pos); + memcpy(report_buffer[idx] + current_pos, buf, to_copy); + current_pos += to_copy; + if (cur_len > to_copy) { + truncated = true; + memcpy(report_buffer[idx] + current_pos - sizeof(TRUNC_MSG), + TRUNC_MSG, sizeof(TRUNC_MSG)); + break; + } + buf += cur_len; + } +} + +static void register_tracepoints(void) +{ + register_trace_console(probe_console, NULL); + register_trace_error_report_start(probe_report_start, NULL); + register_trace_error_report_end(probe_report_end, NULL); +} + +/* + * read() handler for /sys/kernel/error_report/last_report. + * Because the number of reports can change under our feet, check it again + * after copying the report, and retry if the numbers mismatch. + */ +static ssize_t last_report_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + ssize_t ret; + int index; + + do { + /* Pairs with release in probe_report_end(). */ + index = atomic_read_acquire(&num_reports); + /* + * If index and old_index mismatch, we might be accessing + * report_buffer concurrently with a writer thread. In that + * case the read data will be discarded. + */ + ret = data_race(strscpy(buf, report_buffer[index % 2], BUF_SIZE)); + /* + * Prevent reordering between the memcpy above and the atomic + * read below. + * See the comments in include/linux/seqlock.h for more + * details. + */ + smp_rmb(); + } while (index != atomic_read(&num_reports)); + return ret; +} + +/* + * read() handler for /sys/kernel/error_report/report_count. + */ +static ssize_t report_count_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&num_reports)); +} + +static struct kobj_attribute last_report_attr = __ATTR_RO(last_report); +static struct kobj_attribute report_count_attr = __ATTR_RO(report_count); +static struct attribute *error_report_sysfs_attrs[] = { + &last_report_attr.attr, + &report_count_attr.attr, + NULL, +}; + +static const struct attribute_group error_report_sysfs_attr_group = { + .attrs = error_report_sysfs_attrs, +}; + +/* + * Set up report notification: register tracepoints and create + * /sys/kernel/error_report/. + */ +static void error_report_notify_setup(void) +{ + int err; + + register_tracepoints(); + error_report_kobj = kobject_create_and_add("error_report", kernel_kobj); + if (!error_report_kobj) + goto error; + err = sysfs_create_group(error_report_kobj, + &error_report_sysfs_attr_group); + if (err) + goto error; + return; + +error: + if (error_report_kobj) + kobject_del(error_report_kobj); +} +late_initcall(error_report_notify_setup); From patchwork Wed Jan 13 09:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12016213 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 E4B7AC433E0 for ; Wed, 13 Jan 2021 09:17:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 65B35233EB for ; Wed, 13 Jan 2021 09:17:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65B35233EB 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 9668E8D002B; Wed, 13 Jan 2021 04:17:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 93DDF8D002A; Wed, 13 Jan 2021 04:17:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DDDA8D002B; Wed, 13 Jan 2021 04:17:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 5D0A68D002A for ; Wed, 13 Jan 2021 04:17:09 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 25CB9181AEF31 for ; Wed, 13 Jan 2021 09:17:09 +0000 (UTC) X-FDA: 77700197778.23.clam29_160be2f2751c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 028EE37604 for ; Wed, 13 Jan 2021 09:17:08 +0000 (UTC) X-HE-Tag: clam29_160be2f2751c X-Filterd-Recvd-Size: 4703 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 09:17:08 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id cc1so988894qvb.3 for ; Wed, 13 Jan 2021 01:17:08 -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=XzfaCNHUB3u0Xi2wro/cbX3HxJgdcymLpFgEMQn1EeM=; b=D/ltpYSY2gXKcSOhoEH+7aMmW9DFoOQBGhBEMDJ4QS9njGGEQ+UgvD50OFm7WCJiX5 yGRfXzWPCiK/OxgUzjueN77kQfLhClaYsYkiLF4d4L8qq/oN4MTL7Bj4whF0lwwdFXGq vOeiKV0hfSHjks3r0uQ9MblnKoAcmMen4f7t4QSzOwJEJyc8damdK2f/AhX4tS06ga4N zJ3WzEbGl/Sgny/4jWxtwrIMobAkEb9bzIn99LBFf1J7S5EyhQJcLBsnf8NA6hJYHUY/ fgeOqaVP7Ahwr3dgE/izElEMBlXWOOSfC8lhgm4M7rpAT3oqaTqSgAcxngL/L3UrLx/3 h3ZA== 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=XzfaCNHUB3u0Xi2wro/cbX3HxJgdcymLpFgEMQn1EeM=; b=GFWxavDmIieBSaso8KagiSZlc0ukLsR2tvIkPn12OqZ6IoYRtaIm33VBD683gADyQ4 EZNz3FylAsJEEnQUCB9fS2qqqZsrpnQzNhuTudkVHJGyZymjylKu38tE1kopKo7RJGrc 3Dg4glACZGUcXnCT5vDnm0mOsaV2TE8XAHH203e9f2fJL5cnX4VpHSEryqGw/eVRnGJ+ Q0uRCNVH1QxqS98AXTYd+RYlRrrRpQOzqc5yRlabFkGbgTihqaTUwfjFvXrGEwde2G/I dD2+oTjds4lMOTH7g6RRYcf8qDEDAhuhoBeMl5AxKq8azNV7rWaoMUskTLJoZVBFmRzV tvhA== X-Gm-Message-State: AOAM531m3Hof+Yv4nXo3D3id/HW/UZ1hcaX/tZSU/rkNqevBMFmRWdnD QyC/Vn75ZwlvPRmHEqwaVr0VZmTl9zE= X-Google-Smtp-Source: ABdhPJxGEXOWLz12zW+XK9vcOJrU+ahfdiUUJDRxxYmBlkX4/voTJwUyqsSxNEb1r/QpLIRbF9BTV/M43LM= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a05:6214:a14:: with SMTP id dw20mr1243999qvb.43.1610529427925; Wed, 13 Jan 2021 01:17:07 -0800 (PST) Date: Wed, 13 Jan 2021 10:16:56 +0100 In-Reply-To: <20210113091657.1456216-1-glider@google.com> Message-Id: <20210113091657.1456216-4-glider@google.com> Mime-Version: 1.0 References: <20210113091657.1456216-1-glider@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 3/4] kfence: use error_report_start and error_report_end tracepoints From: Alexander Potapenko To: akpm@linux-foundation.org, linux-kernel@vger.kernel.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 KFENCE 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/kfence/report.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/kfence/report.c b/mm/kfence/report.c index 4dedc2ff8f28..5c063b5b2227 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -184,6 +185,7 @@ void kfence_report_error(unsigned long address, struct pt_regs *regs, lockdep_off(); pr_err("==================================================================\n"); + trace_error_report_start("kfence", address); /* Print report header. */ switch (type) { case KFENCE_ERROR_OOB: { @@ -232,6 +234,7 @@ void kfence_report_error(unsigned long address, struct pt_regs *regs, show_regs(regs); else dump_stack_print_info(KERN_ERR); + trace_error_report_end("kfence", address); pr_err("==================================================================\n"); lockdep_on(); From patchwork Wed Jan 13 09:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12016215 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 A7B07C433E0 for ; Wed, 13 Jan 2021 09:17:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1B92C233E2 for ; Wed, 13 Jan 2021 09:17:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B92C233E2 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 8A5A48D002D; Wed, 13 Jan 2021 04:17:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82CEF8D002C; Wed, 13 Jan 2021 04:17:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F5108D002D; Wed, 13 Jan 2021 04:17:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 4D1A88D002C for ; Wed, 13 Jan 2021 04:17:12 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1CC6D18061B9B for ; Wed, 13 Jan 2021 09:17:12 +0000 (UTC) X-FDA: 77700197904.02.fang11_3c063f02751c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 041CF10097AA0 for ; Wed, 13 Jan 2021 09:17:11 +0000 (UTC) X-HE-Tag: fang11_3c063f02751c X-Filterd-Recvd-Size: 6174 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 09:17:11 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id f18so549447wmq.1 for ; Wed, 13 Jan 2021 01:17:11 -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=d4C0PW5sZc0HlVWTO9j0oxt1OwJCzegOR6uDyERunOBnLuzZup+teT4aMNmJkI0FDn YRedWuQrB8arw/Jt5f8VUq/+QPbJDWhLsUjf1ZxaiubNyBX1+XCSQbCj1uQDXMeQkhp5 GOvnj696GHLj2reYj7W8v95JYL5Vxhix7bSbLO6+LFHeyzUutxwmps9ehUheOdsomQdq fLmcjcKFWYgCaPfrwh4ypvmCy3SGwBt5fgt6xepe9j3qHUOtjqEkW3xbA/EILaM2WqSg W3Ni7DYvcAe0Z6iOax0ObnSz4PSTOvl4dBpwTNHucMLpFH1ZAnrA1c4dDYuhwm/E3rA2 YgIg== 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=H+6jRk2Akx6idzYzY6iMBeNgmulPRE1LuZPXA6HQ5xN6MZjWHUcfXQsbcR5ZCYbUsM b/uS8UFc9wx/o4FkjTRc0TnibzqQL58bP2UzqyPatNrsCVqLxbzFMcl0OE7rRh8P4p4r Lwvv1DhFMnq9z22m3N6KIHUn0wA+yxZQQskkIOeetM8G1dTLgVD+iEOXKgIBfVZe69ZB lOfybBtjL0ekJsD4qGnKczhVnz6gEQICa6OMEl/728jTLa9s6hJ7/RF8iNVLS3yZXAjF hYxRS18SsVrc9ddBO3TGNCF0JArSiN+q9Q5r8stTyalqNL5WtrPueXpe/MnovGc4nxvd hj6Q== X-Gm-Message-State: AOAM532fL7ferBiXcpPMXRKkdHo+Zn3aJR+fOXgbmlgBQMniE+GNXxg3 PNNHQkEQf+dYVPJvZQahVbaNMc0zu5w= X-Google-Smtp-Source: ABdhPJz3jt64c/gcj+wvuQCEziz78fmMWTAdkDanZ1a8Y5QATUBLbztfMzxaMeklY7WCE2FLqh5B8RbPUvY= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a1c:5644:: with SMTP id k65mr1225748wmb.62.1610529430509; Wed, 13 Jan 2021 01:17:10 -0800 (PST) Date: Wed, 13 Jan 2021 10:16:57 +0100 In-Reply-To: <20210113091657.1456216-1-glider@google.com> Message-Id: <20210113091657.1456216-5-glider@google.com> Mime-Version: 1.0 References: <20210113091657.1456216-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, linux-kernel@vger.kernel.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,