From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58888C433EF for ; Wed, 2 Mar 2022 17:38:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF4258D0002; Wed, 2 Mar 2022 12:38:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA2598D0001; Wed, 2 Mar 2022 12:38:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B919D8D0002; Wed, 2 Mar 2022 12:38:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id A8A3E8D0001 for ; Wed, 2 Mar 2022 12:38:12 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 76BE424FB5 for ; Wed, 2 Mar 2022 17:38:12 +0000 (UTC) X-FDA: 79200154824.07.7D7D590 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by imf25.hostedemail.com (Postfix) with ESMTP id 080CFA0020 for ; Wed, 2 Mar 2022 17:38:11 +0000 (UTC) Received: by mail-qv1-f43.google.com with SMTP id d3so2079026qvb.5 for ; Wed, 02 Mar 2022 09:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3CWSfAWuGRM0DidB0ivDkq8AFKbglZjIAIWZXun6ksw=; b=pMy31EiU2zJP8kJlFvkMl400zLwVCOXFGVeW3V2JERAMNTt+asI7o8pokyqPE9VSnR WAPYq17nbN3ncIHM5oyNMdb5rwXZmJcb2CqDAXNpbeV++oW8KRLcY0nIBAtpIN4aqhzs DFnyX6XrgXCMbxZCRRe0hx8omNNJQQoKiJMqa9c0OKulo2rLYEwspBHBhU+26KCISjcY 8DTUFjUyU3F1oCVmv+eKoQupAYXvJh9uQpgL8wnxwO+NC2OrZunsh0nI6+MU7pcJo6jv DP2gDB8FUPJGOrAA63tMO9ISZbpxOD2dUoM8/MQZvpSm0Q0jsJMsMNUO6r8JpU/SqQxd ZCIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3CWSfAWuGRM0DidB0ivDkq8AFKbglZjIAIWZXun6ksw=; b=60T0XaU3gNsRwd4gQTtITfJUtiD6EEzsEa1hEpaHxgEuzWqBZzdBqq2jpGMGG3tHSY WHQqxum5aUg18EM4bvIS4ivoQh3vVxXY5nUPefMfR6RvcZNqIB8uL9gmuR4siUJrPjyj 5cJJ/Q74f1xtZGQB+sL+2sJRequLEY7mc86vXVNKBaLDhfxxnneAfmBCAnlNn4u6w+fa jQd+VoTuZRU5H9B/FDufGZzpfr3wR7r1VeMTteOXaucx6y9KJPutLggHAPyLoG40ZARg LewqqDaujNWyNbqLUfcqsh7uL7Mrs+DnDFTxxmAwPd352uUJpvcAuCsdpFPRNSj/44iZ mhlg== X-Gm-Message-State: AOAM532655okhO3UjGG/8WZOIbJfBd+lOZo6tlz34Bl7nKhK2QKGSGTr fVzCSWkEZ2zuo5qdLeOpxEBg+hKkUnB+w+jcl1Fx4w== X-Google-Smtp-Source: ABdhPJw7q6CaIitWaIVHWCEDYzJSarYw1SmLF9/3frGfw1vB9/8nktTdXPEmiBERE/LhUoBSw3ufbmZBoCAKrj0/Nmo= X-Received: by 2002:ad4:5fcb:0:b0:432:d049:c6d with SMTP id jq11-20020ad45fcb000000b00432d0490c6dmr17548321qvb.39.1646242690905; Wed, 02 Mar 2022 09:38:10 -0800 (PST) MIME-Version: 1.0 References: <1c8ce43f97300300e62c941181afa2eb738965c5.1646237226.git.andreyknvl@google.com> In-Reply-To: <1c8ce43f97300300e62c941181afa2eb738965c5.1646237226.git.andreyknvl@google.com> From: Alexander Potapenko Date: Wed, 2 Mar 2022 18:37:34 +0100 Message-ID: Subject: Re: [PATCH mm 06/22] kasan: simplify async check in end_report To: andrey.konovalov@linux.dev Cc: Marco Elver , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Andrew Morton , Linux Memory Management List , LKML , Andrey Konovalov Content-Type: multipart/alternative; boundary="000000000000cecaad05d93fbe75" X-Rspamd-Queue-Id: 080CFA0020 X-Stat-Signature: 3b378w1htsq5y9x6916wtjym3ch45azn Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pMy31EiU; spf=pass (imf25.hostedemail.com: domain of glider@google.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=glider@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1646242691-384648 X-Bogosity: Ham, tests=bogofilter, spamicity=0.044271, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --000000000000cecaad05d93fbe75 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 2, 2022 at 5:37 PM wrote: > From: Andrey Konovalov > > Currently, end_report() does not call trace_error_report_end() for bugs > detected in either async or asymm mode (when kasan_async_fault_possible() > returns true), as the address of the bad access might be unknown. > > However, for asymm mode, the address is known for faults triggered by > read operations. > > Instead of using kasan_async_fault_possible(), simply check that > the addr is not NULL when calling trace_error_report_end(). > > Signed-off-by: Andrey Konovalov > --- > mm/kasan/report.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kasan/report.c b/mm/kasan/report.c > index d60ee8b81e2b..2d892ec050be 100644 > --- a/mm/kasan/report.c > +++ b/mm/kasan/report.c > @@ -112,7 +112,7 @@ static void start_report(unsigned long *flags) > > static void end_report(unsigned long *flags, unsigned long addr) > { > - if (!kasan_async_fault_possible()) > + if (addr) > trace_error_report_end(ERROR_DETECTOR_KASAN, addr); > What happens in the case of a NULL dereference? Don't we want to trigger the tracepoint as well? --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Falls Sie diese f=C3=A4lschlicherweise erhalt= en haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, l=C3=B6schen Sie alle Kopien und Anh=C3=A4nge davon und lassen Sie mich bit= te wissen, dass die E-Mail an die falsche Person gesendet wurde. This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person. --000000000000cecaad05d93fbe75 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Mar 2, 2022 at 5:37 PM <andrey.konovalov@linux.dev&= gt; wrote:
From:= Andrey Konovalov <andreyknvl@google.com>

Currently, end_report() does not call trace_error_report_end() for bugs
detected in either async or asymm mode (when kasan_async_fault_possible() returns true), as the address of the bad access might be unknown.

However, for asymm mode, the address is known for faults triggered by
read operations.

Instead of using kasan_async_fault_possible(), simply check that
the addr is not NULL when calling trace_error_report_end().

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
=C2=A0mm/kasan/report.c | 2 +-
=C2=A01 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index d60ee8b81e2b..2d892ec050be 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -112,7 +112,7 @@ static void start_report(unsigned long *flags)

=C2=A0static void end_report(unsigned long *flags, unsigned long addr)
=C2=A0{
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!kasan_async_fault_possible())
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (addr)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 trace_error_report_= end(ERROR_DETECTOR_KASAN, addr);

What h= appens in the case of a NULL dereference? Don't we want to trigger the = tracepoint as well?


--
Alexander Potapenko=
Software Engineer

Google Germany GmbH
Erika-Mann-Stra=C3=9Fe,= 33
80636 M=C3=BCnchen

Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, L= iana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz d= er Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Falls Sie die= se f=C3=A4lschlicherweise erhalten haben sollten, leiten Sie diese bitte ni= cht an jemand anderes weiter, l=C3=B6schen Sie alle Kopien und Anh=C3=A4nge= davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Per= son gesendet wurde.

=C2=A0 =C2=A0 =C2=A0

This e-mail is conf= idential. If you received this communication by mistake, please don't f= orward it to anyone else, please erase all copies and attachments, and plea= se let me know that it has gone to the wrong person.
--000000000000cecaad05d93fbe75--