From patchwork Mon Feb 1 19:43:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12059869 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 EFFB5C433DB for ; Mon, 1 Feb 2021 19:46:02 +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 95CCE64DBA for ; Mon, 1 Feb 2021 19:46:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95CCE64DBA 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=AQMNUjqhnv7XR7fd7Cvsftj7wAfReiAO7n5tof26pdY=; b=ADPaSPTel6ltsw5qX+ZvUJZ2d C3m8tw/palfv1FC14VZo2Tmz66er9fQdx5sUrsHBrd/7pkoMuybWrldeog5rjRV91/ty8+oqq2d2b oeDo90IjlDmQR+oszCYCWHsxmqOjmH6VB9C/8ai6ELE698FBrQtV7yNjT1NMM2TbKij+tgpwDvI4d EMZVTzSTopUOdQ6+TsZPjmMaUI0UT60Q0ybhOC8MG5ZI29llZmQv0yS6pUWf0OGglyLRY6G/D1QfY XJR3LxJnBKq09zQQ++E/0RSdqeQVUg6e6gQSzZOpouo34F0LmKGCvqDPdCpz6DAAGdMSQnJoKVj0D 9/Y6Dqe2g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6f7W-00029J-PH; Mon, 01 Feb 2021 19:44:22 +0000 Received: from mail-lj1-x249.google.com ([2a00:1450:4864:20::249]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6f74-0001sb-F4 for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 19:43:55 +0000 Received: by mail-lj1-x249.google.com with SMTP id m9so9989245ljp.16 for ; Mon, 01 Feb 2021 11:43:51 -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=vdSQ7N299ttJfkAji9JrIXHPqKuzBqRIB40yh5wvGsM=; b=Phj+HIZS3dxn0owHV5yLJaaC0AGJkEU7TfgxvzoS86S8PoZm4Rt1g+God+bs67EJc+ oAD4CGWKbkQlIIbCUNovOV1zLvhKFi5m+ZzhOblNupaIUd5ggX6TEZOlIrDz5XWmWLta JTZs7Uw7XmdRI9FLQF1x63YHp2a9KJzeObyFVOK0Yf424coQsCFXhiGhs5WSS+Wfdr5+ DV7O2YJKktRTJmORtVpVqwjlVS56TeRw4d0zGoTpGadYHfwg5/12VFuGKUvo3egw2HjJ JyuLK5fUm/yWENE6Hh73fMc8gwZMa7zXTtIL5S8EwT3PsxdE5NtR2aqDG2mEhfgqxwDS Cr8w== 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=vdSQ7N299ttJfkAji9JrIXHPqKuzBqRIB40yh5wvGsM=; b=EIXMGDSRzsItTiEkYfVfj31nI1WDETKtCH2spErdkHg9wqtfdlIMTSDBh33sNgHaJQ yn6m6m//qRDk4QDWlEXHyT32K1xtR7bVUvpqCu9Si/iX5l3ueuHB5EOO9X05pM1APY22 aMez1+CWZphBv59imVPhnWhO5ZM/SSONJVevyJzhzMLLMA/xG7BvjGBabyM3uGZvkZde dg2HyoVVIaOsLnOiwPTB5BNqMrbppoBfGzIcqBg2ottU+TRmEbnlgYiXwrOXvvCB4xL7 B3FgljivWpXPLPMywUP2UQPPU+sh0w9jbCyCE5nljCO9h6Rrxl+KS7CDtql/s5zwXzx9 4CNA== X-Gm-Message-State: AOAM531HNkLKoKlF1tHGN8qGHnOeN1zNhYbqGYkR3/I8FM6pN1AgEmVV YT6b2euAoLIzf34+rmmS7WD+Lgt+uiR47Q+w X-Google-Smtp-Source: ABdhPJyTPeHvPlSg3evueEvog+d2Wbu3vFUyi7JAGczcnckPOWrvdcuYouS1E9V9e/DkjSKSFt3vDyjaDwqvcObf X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:ac2:44b8:: with SMTP id c24mr9569637lfm.155.1612208629709; Mon, 01 Feb 2021 11:43:49 -0800 (PST) Date: Mon, 1 Feb 2021 20:43:28 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH 04/12] kasan: clean up setting free info in kasan_slab_free From: Andrey Konovalov To: 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-20210201_144354_556712_1F9CD2AC X-CRM114-Status: GOOD ( 11.21 ) 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 , Andrew Morton , 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. Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- 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 a7eb553c8e91..086bb77292b6 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); }