Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp162262pxm; Wed, 2 Mar 2022 12:32:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQnFY4M76bEcgp6iqnGDlgAtfSmgVCvaGL3PxpU7KTVMaTcytzk+MkEJdw2+cBvgLRLCNL X-Received: by 2002:a50:d496:0:b0:413:2cf1:efb6 with SMTP id s22-20020a50d496000000b004132cf1efb6mr31209793edi.150.1646253136430; Wed, 02 Mar 2022 12:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646253136; cv=none; d=google.com; s=arc-20160816; b=Uu0yksTheZf+SuqfGzhMh6QSOkrJoQdTxucd3VRfsRlUUI0PrmLCKQQB+YFbqwvauk DQD+0QzTPX6vP1H4Hz8sbdeaAyWDQtPXFe12gHuoqM5zJ+/oL1IAYhh6cZfrqToRc0z/ v0Dp3F21kRsAyRRVnHwHNEGhOrhgIE895ER/ca/iD9uvsplA+nBnV+vbNvPfPkL0GTYv I5vHdaZ0Rtwx/x5XoR7R0+DHSIR4ZdKHWciAY2hCcS7gl40wHhGohRkd+kyhfga3Sd0t 62oQCoZzJYHiytJMuEcF142b+IQv3MAev/rG762OTZSW0r4TLfD/VzdPBNSBZDgpGcbq wr8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GA4CzC5kQCyt9Q46WjPbGlANWaRE9EWTbe6SrvYEjAk=; b=zKEph5r8OvqgjVMd2pgAy2THYe/TBRMCUQaJOlLESFszsCR+Y9z00a2cHfM2Puo99E ecBsnN53xgsdgvUx7WjxEAk0TCVF2DHeqUGl2bo/LBR7XiVJ9tj6Jbv9q4nnVTQFgWD7 8oDzUVAwA97a500Sl4MLWd01zfL1UaoRXpMU9uHBtDxVTP1EJ7zZCRgl352OGtzZuCDn PFaXN7Vve87HGXvozKQj+3ckPMgK7PM1xoftFHhgHQNEd2H84OOKoXOYAPtaPzTtLh3I FfPtjE8/YBoA7hFA7PAKuS9AdYsY1JmevgN6PQ1QWZkakaOz+ggCj44HKubmWoPMjgvX eN0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=aaBHXo5y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020a170906148d00b006d6e74356c8si42651ejc.4.2022.03.02.12.31.52; Wed, 02 Mar 2022 12:32:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=aaBHXo5y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239261AbiCBQjq (ORCPT + 99 others); Wed, 2 Mar 2022 11:39:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236727AbiCBQjn (ORCPT ); Wed, 2 Mar 2022 11:39:43 -0500 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749B163BCB for ; Wed, 2 Mar 2022 08:38:59 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1646239137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GA4CzC5kQCyt9Q46WjPbGlANWaRE9EWTbe6SrvYEjAk=; b=aaBHXo5y2T1+Vm+RNaREb41iINBlTfgGfciO9VaNYAxyxUoq7gYiXaDkPdMoxsduX3sA9g TzAIUkekbB8xhUA3Qo3mXL+z0ndkfEB2sBoCKWQJ2d3hO4mxiEgs5KkR9zFLzvL95BCF95 U/IBKTxSoTLvCJszTBkqfdNgKa1YG4o= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 13/22] kasan: restructure kasan_report Date: Wed, 2 Mar 2022 17:36:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov Restructure kasan_report() to make reviewing the subsequent patches easier. Signed-off-by: Andrey Konovalov --- 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 a0d4a9d3f933..41c7966451e3 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -457,15 +457,18 @@ static void __kasan_report(void *addr, size_t size, bool is_write, 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; } -- 2.25.1