From patchwork Thu Nov 5 00:02:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11883047 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=unavailable 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 06E3BC00A89 for ; Thu, 5 Nov 2020 03:37: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 7115E2072E for ; Thu, 5 Nov 2020 03:37:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cGqzk43l"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RDzC0GFG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="jrZ3nq9h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7115E2072E 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=OSFS38E+m5rK6xlhO/uCkGDy8iTxt+ZPiQUjQXktpkI=; b=cGqzk43lrIczUG/AivAsnL0b+ nDaOvvldGIsgUQ7jvbEBi9yZYOuahizB6/EkW0Ls71L1gcMNFB7rctPAoO/KjhR5DAyAEv1qFynki 8PiIK+rz7w1vsHHosmcE0SYXqGoxvT7DgKqWTEct1/KK28pTz0uu24re6v855fzYubtL5B4AfBsSl R/GX8+bnHS8iG+soxKL2DpAQXthsmuCC1JqsLBo/zHXpo28TE9/m49YxsP9s/8ND7AVE/CrTyMbCK 6+EcQe0SDHVsfz0yTeb0G+qvbBfMNI7CWpV6nuWj2DNKt6MCvL9/8O5UEiB9BgK+G8U0x8nSmJqZ9 1IV/BJ+0A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaW4q-0001z0-JY; Thu, 05 Nov 2020 03:36:44 +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 1kaW3o-00016k-MY for linux-arm-kernel@merlin.infradead.org; Thu, 05 Nov 2020 03:35:40 +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=n/EgrjS/0wTVW1eC4Y9BfE2JdZzS0OcWlZnzEp1P2oA=; b=RDzC0GFGA3qbkPl1aFwFAoxVyc ZlfIOsDeIOl7N9KeFPDVUFGenlVMedAShpHzUg1ZLgQvYk3qZv0Nnt52ijNzuvLbUUHRBClGOwgIJ h4kl5URcbWQfvaaSqObBdP4YFGMbzkDDHO4ps7TMChZtDlEUaBjW7w6s4zVAMIUMn5FdDU6QhJ8ID kOIuRRAxan6UPU/kn1mx18sNta81Ci8o41f8ocSsc4+3uilvmnAqRr6Pm4iuPD2xrOa07y5pxHd0P Ofkbvq8U/JRcxv3m8XizyGx8Vv/r0E5FNG17RREA/jHaoX8NPNEHXrEio3KChFVZrbdatDqEX1zaD nf4QaNBQ==; Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaSl8-0000rW-Q9 for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2020 00:04:14 +0000 Received: by mail-qt1-x849.google.com with SMTP id 22so127433qtp.9 for ; Wed, 04 Nov 2020 16:04:10 -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=n/EgrjS/0wTVW1eC4Y9BfE2JdZzS0OcWlZnzEp1P2oA=; b=jrZ3nq9hvCyDk1RywcRDcNGLi6wEaMLQe6lPvnUPEYicuoOqjT3eav85cW/BXeq2ZN QVOCcds43Wnzx3dOnutChSfKv1NVao6weEX+bhbFjRbzNcdGAsbsHrc959Cjb8TQGLeI QvY7yMKKV2eGthNdRftUUMd1mqd3sADjDOTmOzxQGQtW9yKhpco958xzs3qnh9LWUpNB Vf5EwNZxVZ/etFX2hS0qJnRqlYILtSSHtGEPqZ+C4i+NiiIotBy3GT2UPg4dw7/VpXiT 8bDZtmQaKFqy0pr6z+S/70zL5rJgVmIhQfN3xyX7xUwnbUIZ8XcIhY12Sfv6sAIVSOsC 5Eyw== 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=n/EgrjS/0wTVW1eC4Y9BfE2JdZzS0OcWlZnzEp1P2oA=; b=ntso07x0P2Q0m1wpgqVFCTU+q6/YeMpAiKKuamI61BSyQ7kaM1EcEhWIKFVHN5p2cU ApsRsYg/Uj03yaRBv426TXG8c+0f+tMe/25tUbtVbuRpr9Ihmsbaadz1BlqVCO13MKCA wTnPJtnqjsGqoZBCnj8cL44E5KTgEflRevSjra0z1lWXImR8LKnQm4Zzla709OFa3wy4 D3fLW+HPWrfi2TnoTTAXuvh1LacaMJulG1ZByta2/w9nmSdCTIvX6ebqt8ouvQA5gj4x A7pGL4b5UHZZEuknJj9dLX1qCwflhSUr5Vt9nZI591lum/OHtqG12o6VV9NN/wedN+34 nL8g== X-Gm-Message-State: AOAM533/pMhWXwE1XpcXgAQ4nrYRbv7r1m30AL9sA/0c7PByP3vYe/hs JKxpaLHhDi91kFr8H2ITmJQFPtCYks4OcyyI X-Google-Smtp-Source: ABdhPJzX+fSBMSD2Sr3BapYXMWINq8pPniVZsem2D0Y9Dv2YLtXgN5Ei9MAIzJTjyzHz2heVRtUdpAvUTBisVAT7 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a0c:f70f:: with SMTP id w15mr489369qvn.45.1604534588580; Wed, 04 Nov 2020 16:03:08 -0800 (PST) Date: Thu, 5 Nov 2020 01:02:24 +0100 In-Reply-To: Message-Id: <82f01c35335ae293f6119531670354116fd63858.1604534322.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 14/20] kasan, mm: rename kasan_poison_kfree 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_000410_984788_7EA20E4F X-CRM114-Status: GOOD ( 12.72 ) 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 Rename kasan_poison_kfree() to kasan_slab_free_mempool() as it better reflects what this annotation does. No functional changes. Signed-off-by: Andrey Konovalov Reviewed-by: Dmitry Vyukov Link: https://linux-review.googlesource.com/id/I5026f87364e556b506ef1baee725144bb04b8810 --- include/linux/kasan.h | 16 ++++++++-------- mm/kasan/common.c | 16 ++++++++-------- mm/mempool.c | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index ae1046fc74e5..d47601517dad 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -175,6 +175,13 @@ static inline bool kasan_slab_free(struct kmem_cache *s, void *object, unsigned return false; } +void __kasan_slab_free_mempool(void *ptr, unsigned long ip); +static inline void kasan_slab_free_mempool(void *ptr, unsigned long ip) +{ + if (kasan_enabled()) + __kasan_slab_free_mempool(ptr, ip); +} + void * __must_check __kasan_slab_alloc(struct kmem_cache *s, void *object, gfp_t flags); static inline void * __must_check kasan_slab_alloc(struct kmem_cache *s, @@ -215,13 +222,6 @@ static inline void * __must_check kasan_krealloc(const void *object, return (void *)object; } -void __kasan_poison_kfree(void *ptr, unsigned long ip); -static inline void kasan_poison_kfree(void *ptr, unsigned long ip) -{ - if (kasan_enabled()) - __kasan_poison_kfree(ptr, ip); -} - void __kasan_kfree_large(void *ptr, unsigned long ip); static inline void kasan_kfree_large(void *ptr, unsigned long ip) { @@ -261,6 +261,7 @@ static inline bool kasan_slab_free(struct kmem_cache *s, void *object, { return false; } +static inline void kasan_slab_free_mempool(void *ptr, unsigned long ip) {} static inline void *kasan_slab_alloc(struct kmem_cache *s, void *object, gfp_t flags) { @@ -280,7 +281,6 @@ static inline void *kasan_krealloc(const void *object, size_t new_size, { return (void *)object; } -static inline void kasan_poison_kfree(void *ptr, unsigned long ip) {} static inline void kasan_kfree_large(void *ptr, unsigned long ip) {} #endif /* CONFIG_KASAN */ diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 819403548f2e..60793f8695a8 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -336,6 +336,14 @@ bool __kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip) return ____kasan_slab_free(cache, object, ip, true); } +void __kasan_slab_free_mempool(void *ptr, unsigned long ip) +{ + struct page *page; + + page = virt_to_head_page(ptr); + ____kasan_slab_free(page->slab_cache, ptr, ip, false); +} + 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); @@ -427,14 +435,6 @@ void * __must_check __kasan_krealloc(const void *object, size_t size, gfp_t flag flags, true); } -void __kasan_poison_kfree(void *ptr, unsigned long ip) -{ - struct page *page; - - page = virt_to_head_page(ptr); - ____kasan_slab_free(page->slab_cache, ptr, ip, false); -} - void __kasan_kfree_large(void *ptr, unsigned long ip) { if (ptr != page_address(virt_to_head_page(ptr))) diff --git a/mm/mempool.c b/mm/mempool.c index f473cdddaff0..b1f39fa75ade 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -104,7 +104,7 @@ static inline void poison_element(mempool_t *pool, void *element) static __always_inline void kasan_poison_element(mempool_t *pool, void *element) { if (pool->alloc == mempool_alloc_slab || pool->alloc == mempool_kmalloc) - kasan_poison_kfree(element, _RET_IP_); + kasan_slab_free_mempool(element, _RET_IP_); else if (pool->alloc == mempool_alloc_pages) kasan_free_pages(element, (unsigned long)pool->pool_data); }