From patchwork Fri Mar 25 01:12:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791184 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 36DFFC433F5 for ; Fri, 25 Mar 2022 01:12:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3C0D8D002A; Thu, 24 Mar 2022 21:12:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEC1C8D0005; Thu, 24 Mar 2022 21:12:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADB5B8D002A; Thu, 24 Mar 2022 21:12:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id A04588D0005 for ; Thu, 24 Mar 2022 21:12:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 70E0C2039A for ; Fri, 25 Mar 2022 01:12:51 +0000 (UTC) X-FDA: 79281134142.01.534C40C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 019D3120009 for ; Fri, 25 Mar 2022 01:12:50 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6FAF66187F; Fri, 25 Mar 2022 01:12:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2BAAC340EC; Fri, 25 Mar 2022 01:12:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170769; bh=Nat5VhE6ziYLM5744IzlQUedh3QSwQxGNrwwuNLYEEw=; h=Date:To:From:In-Reply-To:Subject:From; b=RRFoM3yRfXQo5mWu0cKEYElV1Ftw1zJvU4/JBy9gcG/ORHKDK92wzdWAEfFVv/r4w PlxhmggxT9Ia/SwZntMpjqIp1XzkeVUwZdIoV/7A120jtNuiqmg7UMxzvt5m7rYsn/ 9XhoFZ4biOpWxj61c2qHMrdFWRdrElf6MpOFi9a4= Date: Thu, 24 Mar 2022 18:12:49 -0700 To: ryabinin.a.a@gmail.com,glider@google.com,elver@google.com,dvyukov@google.com,andreyknvl@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 085/114] kasan: restructure kasan_report Message-Id: <20220325011249.C2BAAC340EC@smtp.kernel.org> X-Stat-Signature: sz5aara3x69pfw5t3t4qk4frr6jf4h7q Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=RRFoM3yR; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 019D3120009 X-HE-Tag: 1648170770-77352 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: From: Andrey Konovalov Subject: kasan: restructure kasan_report Restructure kasan_report() to make reviewing the subsequent patches easier. Link: https://lkml.kernel.org/r/ca28042889858b8cc4724d3d4378387f90d7a59d.1646237226.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Marco Elver Signed-off-by: Andrew Morton --- mm/kasan/report.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/mm/kasan/report.c~kasan-restructure-kasan_report +++ a/mm/kasan/report.c @@ -457,15 +457,18 @@ static void __kasan_report(void *addr, s bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip) { - unsigned long flags = user_access_save(); - bool ret = false; + unsigned long ua_flags = user_access_save(); + bool ret = true; - if (likely(report_enabled())) { - __kasan_report((void *)addr, size, is_write, ip); - ret = true; + if (unlikely(!report_enabled())) { + ret = false; + goto out; } - user_access_restore(flags); + __kasan_report((void *)addr, size, is_write, ip); + +out: + user_access_restore(ua_flags); return ret; }