From patchwork Fri Feb 5 15:39:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12070351 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 EF141C433E0 for ; Fri, 5 Feb 2021 15:41:13 +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 771F7650F2 for ; Fri, 5 Feb 2021 15:41:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 771F7650F2 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=pHxdr0HdyLeGxMlbgLTjDg2G+ VtFL0FAls5HhYmT5vAERcScZx5k5bOMOlfPS/w8oUCGbPEx8450xPQhSqIScTTfIYQrBmRETY21f4 wYMZqscythfE+PgSp3DpV3uMYBoZ890ZcjA5narmjY5AZmj4n3dYQjZyWd2dwuA+8gN7vXC2ilbE9 v/5tPwLMpTo1MH3mMa0eawakqizLtEP5T2kFKFL2yX1f3ppehcOHswHgBZvVo8vHsJCfqYplHjojT Wbn4MmFS1AQDPIC3PQEKrBdwMPIg73QpkBICpxeZWo5sCIfcQgvXld6gl4JhdvMvF/GZu65p04cYD YzygyG3Dg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l83DB-0007xX-Bw; Fri, 05 Feb 2021 15:39:58 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l83Cl-0007lJ-C2 for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 15:39:33 +0000 Received: by mail-qk1-x749.google.com with SMTP id o16so6133690qkj.15 for ; Fri, 05 Feb 2021 07:39:28 -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=lF3JI1Wz7SI+mSyZFHoJHyreQdSUTq5QY643cGS9GBBxjPRvwFD+iqezyeavSwGDTF uMprUNPCKb6jIjNQ9H27Fur8RtWhiDepPMiibytUc1NJTu0f7IFzzowNuNjrqBgmlLiv 7Tr4SU49efZvmHAiHw87MpqB2rqt/EdI6B3iqynlt/57vW11+kQCzeiLS4vtTtF/ES7x 3KkjctyAS2VhFEOvDpZJ0NSt8AamjRfvI1fi97PPs+ONtwsp9zEj2O5BeVMpwlZmNVVm vJzDRFXwJbhi9UAyMxR5Qu1VM7ormDH+bsHuZ7T8/e7tIEZCLXPYodKzTASn4vvBqtYJ 5c/w== 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=N6TVrlgYiTBaQ1aMbmtXbs3o3NTJRilafUcDVQlyY5LYwJy09XHndzrzg91nbuhdMC GGCjwD+y/3gqQhx0F+JA0I32NTUmTGqK85t1V/SikoetaZfmY2v6a8LOmo+wuaKAr4In IcFK/BAY/aarAdSPwTcimpx80Gj6QqpuPq1jHQq5h6vgirDTaGfSQBgYWgx4Xw7t3UkQ 9L0ij5TYcfVfnRFI1CO5eJgKdK8YE9aqnwryLWqVIKNL6vAd7lHZx0PrZoFAAgDRQS2h nWx18t8AzHmlUid4a8iDTyGhewYqH3FvdYNss5QHuvR84jKiGCKYVPD4Yp1pQUz5xaRX Kx1A== X-Gm-Message-State: AOAM5300KlSNDHH26HE+hZdtwxSO1t+fv3midTa+9ea4uHP6WDPu/Q6C 5xnk4QawM/+q46Wu0wc6r+aLBRzXekz5H5P+ X-Google-Smtp-Source: ABdhPJzwsewfz/TZInoLtcuvYaZ0I40Qn7oK2vNyTP6uAYb18yvMtG1+sQlLK+ggxuOgSY+2gruJ4PNGKknNJrtO X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:edb8:b79c:2e20:e531]) (user=andreyknvl job=sendgmr) by 2002:a0c:eda6:: with SMTP id h6mr4862060qvr.19.1612539567383; Fri, 05 Feb 2021 07:39:27 -0800 (PST) Date: Fri, 5 Feb 2021 16:39:05 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v2 04/12] 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_103931_544435_95CC17A3 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); }