From patchwork Tue Nov 10 22:20:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11895665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B306F138B for ; Tue, 10 Nov 2020 22:21:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7924920781 for ; Tue, 10 Nov 2020 22:21:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="nWOy4NUD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7924920781 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B8C506B00A5; Tue, 10 Nov 2020 17:21:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AEB586B00A6; Tue, 10 Nov 2020 17:21:04 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 963476B00A7; Tue, 10 Nov 2020 17:21:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 626896B00A5 for ; Tue, 10 Nov 2020 17:21:04 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 09D26181AEF10 for ; Tue, 10 Nov 2020 22:21:04 +0000 (UTC) X-FDA: 77469930048.27.air89_5515f20272f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id DD8743D663 for ; Tue, 10 Nov 2020 22:21:03 +0000 (UTC) X-Spam-Summary: 1,0,0,374d744fb6f11a13,d41d8cd98f00b204,3thkrxwokccm9mcqdxjmukfnnfkd.bnlkhmtw-llju9bj.nqf@flex--andreyknvl.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:965:966:967:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2525:2559:2563:2682:2685:2859:2902:2911:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3152:3355:3867:3872:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4118:4321:4385:4390:4395:4425:4605:5007:6119:6261:6653:6742:8603:9025:9592:9969:10004:10400:11026:11658:11914:12043:12296:12297:12438:12555:12679:12895:12986:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:21939:21990:30054,0,RBL:209.85.128.74:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04y8eiig8qhzi9wzzpw4583msf7hkocogxz69frsqq7nnfajmuos97hjpx67ewh.t3eca1f8iqkkmcss5q76adze5po7we4exmch531twi5nr7a4nn43cit6jg7strj.h-lbl8.mailshell.net-2 23.238.2 X-HE-Tag: air89_5515f20272f8 X-Filterd-Recvd-Size: 7278 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 22:21:03 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id u207so1866708wmu.4 for ; Tue, 10 Nov 2020 14:21:03 -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=GOGJv8k49mZ7izGKRKf2lz4nE5+QAATrVFhHt9hU4vk=; b=nWOy4NUDHFOJEkxt4HeQuuF7ItikIUR8FEDsoSuy97fbvULA7lagn7eN3aC6vpstwF xnpFycGGrQwC8h/x/TXHWw0CW+G4Fjd4Slr9kUN2ThO1uqV1a17ThYYrVviz2QzvLoEO oWgn9eARxtVrIcMhHtbgK5vf157PytkMdr0TozM3dqyYiXD2fg1TZOmiSH2tfoQNyg/p JnBT4n1XAgbGk9xq5rgIyLRbUehOrg15Syn4bQ069qKNf+WaK4exp2ytMFY2Ps2HZxgG ZfB1I1UrMfNw1Gz86u3BfC24ZC1yd4ha4aaLaa9otfPc1GMwphpeAJEn2q3FmZCaeW05 uz7w== 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=GOGJv8k49mZ7izGKRKf2lz4nE5+QAATrVFhHt9hU4vk=; b=QfKsbeKZZQkGWEmwgoVyxkMwyCUwL1Fy37NJd7EM+KuEGiyXCPCgEmSJMlZuf4msww h8S5WNW0fgzYwZalGc8tMfjYg5Gx3e8+Zg7lUW1QMqbSOdC3tMCuOoxiEgPcTqlTkA2i R7DlxWLPo2TGjhrzRd91SDjcjriDM7LrjiASEee4jV8bmR631kcr9D+T1bljVz+Hl114 Etbi8ng7uYvZVEyEihOTyb7g/UvR7C+TxxC2c4TxbU7gyg2oeKoDyqOWuq75XX+FNjAe QE2zytgA3O2Kj1PJ5utscKCerNse7N/dlaKRn3Dqqh02uIaQqiWPFbyMegQsVYVIJ5qD xalw== X-Gm-Message-State: AOAM531mfwjxJpUFtyECBcnMcHfdqdjdkAlSOOoQQ621wExojhDfUqGi SAdb76cGy72u5yPyXC0ur2Ekj06zu50+fg8a X-Google-Smtp-Source: ABdhPJye7812Tl8RDG0JMOImadD+I+Ef01WcUzHZ3QitQU3NwVahUAiU8MWUn0N3DMR/yxe7K7D4GjlglR/6liPr X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a7b:cbd7:: with SMTP id n23mr302280wmi.142.1605046862286; Tue, 10 Nov 2020 14:21:02 -0800 (PST) Date: Tue, 10 Nov 2020 23:20:18 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v2 14/20] kasan, mm: rename kasan_poison_kfree From: Andrey Konovalov To: Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Catalin Marinas , Will Deacon , Vincenzo Frascino , Evgenii Stepanov , Andrey Ryabinin , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 779f8e703982..534ab3e2935a 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -177,6 +177,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, @@ -217,13 +224,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) { @@ -263,6 +263,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) { @@ -282,7 +283,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); }