From patchwork Fri Feb 5 17:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12070581 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 55A32C433DB for ; Fri, 5 Feb 2021 17:36:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB26864DBA for ; Fri, 5 Feb 2021 17:36:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB26864DBA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2pTM4Abs60f8Xohq1WuYazGkHj0xpztWcE925au1Huw=; b=qw0jzMmMEopmn3iUIWrgOuf3R HM5zOSsTwRbqv2LcC1aA+RyDtn3vXv8vaYpnOOFm5GVoRglMiJ46Q86j4b3KghkUvqLxeUvwm8mvl KDc4sEXq8QnpvzW9cl8+t0v3IceXPvTixebYLAWv4j37esPredI6CnuVxO0D+d24iJuKesRLs3d57 l5LyifW5ydM9/PWgZM4mj0CW87FizG3aflZgzFG880iHvz+d4KS2237/ogPoRjBB6VVUao2VGHSXT 5MsKnLprWm2U1/Cx2Qv3+bcvbwy9IwQD6IcPRDqyIHHJea6e+pKOVzV+KL0RoOimSudLN+AUiBRvk I2hcvokRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l8519-000560-O8; Fri, 05 Feb 2021 17:35:39 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l850Z-0004qR-8a for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 17:35:11 +0000 Received: by mail-wr1-x44a.google.com with SMTP id u3so5710789wri.19 for ; Fri, 05 Feb 2021 09:35:01 -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=p2PHZd2SW9nz4o7+ZB1C3vkb9xhx8DH7M49Qc2p69KA=; b=CHtaYiFloTo1h3fJ4zIwrdm8kH9MlR88HYI0/PTh1ZWy7A7CwjuDxNrv9Gx69/d5EU /uH5wwsCw9lrcu3UgF0woJeX8LvF46mbIjl1UXDMCFstkACeUmi7LjrhuV3m6VC1O4FA kLqgo4s84+U9SrE4Ij3D8TumUHcGxjFAg+UvRisEMQ4KFqgiuA/0irNBtFKpJm7Y2yvr rv5nooR3qty/BvdTJILjp8ZF4GmyrzIoPmJkwuLqIJMGj3IC94nPtvOTvoNrBK4XD6v9 DrdflvRnrv/sqjoyw4HnrP0YYgEVd4PzvqCF+NE7zyq5KY/kgr+v0ibadQ+YFmPfzDvT 14Rg== 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=p2PHZd2SW9nz4o7+ZB1C3vkb9xhx8DH7M49Qc2p69KA=; b=YKFTP/HFP3DrRZhn8ijMJ0AckIC4yMdXRu727FpLnKDqLVwLYqSfHjPU1nsrB2ixcB md0FbwZuAwgis3kRUFa+JEyLMX1O1EBjAWUz1cyYw/GJO5ofJMgLVSa7WD2GSTQ9aXBW MuxAHzFqieDdHmH2iTiBxRs/T6tlv2DeuWOFtDdlf3Lbjgyln4NJ/zwGtX+Rhhh9xHu1 maPupHzY9EC5gTir9YLwqGed84rn3ALxy2aMWZy0doKSnEHHKBayn2+Y3VUUv/NPvQPM ULCEI72LOSEAQjAP4GzoIjyAWWeiYvZeYkLXZtZZEKeE9oiJeYVZMS+Lri8JAt9qEcXe H/rQ== X-Gm-Message-State: AOAM533rdwiXdePZXBpZif4mq6+q3DUz3g+s7MPYnnTsSH+N/DVCZTUf +tRGD2KuY2LGjm0I8H5SPGAiHUZ3Ii4QC723 X-Google-Smtp-Source: ABdhPJwIwsTCSScqaKOmzq93PUblNEb3imIDP3qjpFcJgdUvxRfwSWqIL28ID41mG6cwO7YBgmA2OyAuujnKhGSd X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:edb8:b79c:2e20:e531]) (user=andreyknvl job=sendgmr) by 2002:adf:800b:: with SMTP id 11mr4807938wrk.322.1612546500193; Fri, 05 Feb 2021 09:35:00 -0800 (PST) Date: Fri, 5 Feb 2021 18:34:38 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v3 mm 04/13] kasan: clean up setting free info in kasan_slab_free From: Andrey Konovalov To: Andrew Morton , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_123503_491234_57CD609B X-CRM114-Status: GOOD ( 11.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Put kasan_stack_collection_enabled() check and kasan_set_free_info() calls next to each other. The way this was previously implemented was a minor optimization that relied of the the fact that kasan_stack_collection_enabled() is always true for generic KASAN. The confusion that this brings outweights saving a few instructions. Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index f2a6bae13053..da24b144d46c 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -350,13 +350,11 @@ static bool ____kasan_slab_free(struct kmem_cache *cache, void *object, kasan_poison(object, cache->object_size, KASAN_KMALLOC_FREE); - if (!kasan_stack_collection_enabled()) - return false; - if ((IS_ENABLED(CONFIG_KASAN_GENERIC) && !quarantine)) return false; - kasan_set_free_info(cache, object, tag); + if (kasan_stack_collection_enabled()) + kasan_set_free_info(cache, object, tag); return kasan_quarantine_put(cache, object); }