From patchwork Thu Nov 5 00:02:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11883273 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 6421CC388F9 for ; Thu, 5 Nov 2020 05:14:03 +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 AE2A62083B for ; Thu, 5 Nov 2020 05:14:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JDYQRqxr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UwrCYcnl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="TKDRruDc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE2A62083B 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=8HEHAwtuxp4zao36wKO2ABmbHTlULKy2EEaCOvl5yIE=; b=JDYQRqxrQf3u4Y9oDfPBfdhpG IfxM+uL4wN4TOXK8yDjoYg/CQ3V1AF18f40PLFvhfIFf+8oQPIVk6rzxt2oWUxKB9Dc169ZTRW60c zzAqLBqc0pfmHtC+XOw6cX+aapTqpQpw07k2eb0eRuk2aOSeGcu839IcwbMHmE8K4G50CqS3kM1pf 3uF4puScdV/MML5nKbaOh+R0Ch4ELPHsspVypiXLb+JSC8C4SiMaMfG0RLzaR2xxWzGUq9vaNk5/T u6AphaSq5RoJYrykAsJ2zQ8ockXp71Q4SO2EPyHbIcPG3tc8YoZ0NZ9qjIOXbfbmEvXZOaR+rcxdZ oTK/DgQCg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaXYa-0007QY-HB; Thu, 05 Nov 2020 05:11:32 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaW3u-00016k-Nx for linux-arm-kernel@merlin.infradead.org; Thu, 05 Nov 2020 03:35:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vCuap+Z40WCfgwTrVBGRXx2rimwF3+Nybx2YvcmvQUo=; b=UwrCYcnlYctrO9fAt9BtGExukz pe8geK2HnmBpGElsbcviTWBLNx/vwZ39RdBlzKieEFGxn/ItVvNEobmEYAnxVy99s1z/UjZbtBNxx 5BWENF6EOkBhQb7sD8jpDqEGIFbXon2zDw7PTYweVCHk9b+/vf2Y5SabNt0w4wwlMsDmO8iuAJgYx cP6XNjRzc87ZjY1PmWEsHBUU0IZTWU9314u2k7oKSQ/iQkAj7ml4R5FCNclSV2wtzQnW1EHgYBAjH g1g3djrE2vNjbMafj1YNqarBsMXherE30W/Zy3oWkQBw5kMKPIbXquu0GgQTzvBSzj/FTN9OCudpZ mLmt9t+Q==; Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaSkj-0000n9-DY for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2020 00:03:47 +0000 Received: by mail-wr1-x44a.google.com with SMTP id w6so103144wrk.1 for ; Wed, 04 Nov 2020 16:03:44 -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=vCuap+Z40WCfgwTrVBGRXx2rimwF3+Nybx2YvcmvQUo=; b=TKDRruDc0EPKdW5qP5kZx93U6ILuVOKa9NRxOsJBSbrsNehB2La/XSXsAe/9hQyaMk yCK6FVozl9zmqc2IUI/9cYSE7LNyU/0mpvnpHD2T8bl7AVgkRNS2UNY1OunTzaHIAXdt FE91Mn1bMT+89GiGiG+pSKXKCCCi7QTzrqooRDTGgQ6Ctjnx1U3rrYtD1VR4mL6FgcFK c/85JUoGFBsSf4jLoyMoeAlfhJucBZFp+w6YrIBmmw+RbFgil2rQH+u6WqYjog3CXg9X fu8SkOWMFfLel2sGmtiWpsbMBhumZ52ebQMgrd624Xe4e6DKIvYVbygT2KF7gS/efkdd Cm0A== 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=vCuap+Z40WCfgwTrVBGRXx2rimwF3+Nybx2YvcmvQUo=; b=hnhxH/hjIs6JLH+wqReol6IuCUvRpItCeIa5cXE3fGx2CwBeGvKPzNLRRO3EANx2Gy OlXR7nQK3JADVvPOFGrhp+ERFh/alMwJAy9BiddHpwsQCbIOLI8xWfGgBwCCMAlvNbJf PvAPpkPxXU3d1sPwpeK1F3uz2gpEaVh22toTm70+qpq9VhcJO5b0KeEH7mgsl2mco+Bt QuPWOSizwfe/Pbc4P9Ju8KzBU0YeFDyF4fnBhg3jNPULwCgzwF8aHINjp1abtEQMwFdU vlWHJwsu8Igo7vuZdfFJ46GIJevYaZ3cGrlBpYup42oEumkEaUsBN0NpW2NmdtskZXk+ DPvA== X-Gm-Message-State: AOAM531+7GLnisIyBWLE3qRsIoLBDDRYc7u+f3soC20WNkAs1RtFvdeo yQqGra1PdexEqZvtHbdVbCXzLB83KPJzbhli X-Google-Smtp-Source: ABdhPJwuuyHLeDdD+KHqiqHb6fDGG/rhTQChDK6P5WB9OmWfgwhMcOyy6D+DkRkEMkd2PMl1yMhO3tDZC6Em3M7m X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a5d:4d0d:: with SMTP id z13mr477608wrt.23.1604534562699; Wed, 04 Nov 2020 16:02:42 -0800 (PST) Date: Thu, 5 Nov 2020 01:02:13 +0100 In-Reply-To: Message-Id: <4a32aecc6761e93d792cb2b78af86689025627bd.1604534322.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 03/20] kasan: introduce set_alloc_info From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201105_000345_581877_705D118A X-CRM114-Status: GOOD ( 10.79 ) 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 , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Andrew Morton , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add set_alloc_info() helper and move kasan_set_track() into it. This will simplify the code for one of the upcoming changes. No functional changes. Signed-off-by: Andrey Konovalov Reviewed-by: Dmitry Vyukov Link: https://linux-review.googlesource.com/id/I0316193cbb4ecc9b87b7c2eee0dd79f8ec908c1a --- mm/kasan/common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 8fd04415d8f4..a880e5a547ed 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -318,6 +318,11 @@ bool kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip) return __kasan_slab_free(cache, object, ip, true); } +static void set_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags) +{ + kasan_set_track(&kasan_get_alloc_meta(cache, object)->alloc_track, flags); +} + static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object, size_t size, gfp_t flags, bool keep_tag) { @@ -345,7 +350,7 @@ static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object, KASAN_KMALLOC_REDZONE); if (cache->flags & SLAB_KASAN) - kasan_set_track(&kasan_get_alloc_meta(cache, object)->alloc_track, flags); + set_alloc_info(cache, (void *)object, flags); return set_tag(object, tag); }