From patchwork Tue Nov 10 22:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11895663 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 7758B138B for ; Tue, 10 Nov 2020 22:21:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B30720674 for ; Tue, 10 Nov 2020 22:21:04 +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="Sorzbxjl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B30720674 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 548B06B00A2; Tue, 10 Nov 2020 17:21:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4D4896B00A3; Tue, 10 Nov 2020 17:21:02 -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 260BF6B00A4; Tue, 10 Nov 2020 17:21:02 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id DB75C6B00A2 for ; Tue, 10 Nov 2020 17:21:01 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8C7391EE6 for ; Tue, 10 Nov 2020 22:21:01 +0000 (UTC) X-FDA: 77469929922.22.nail72_5302286272f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 546E718038E6B for ; Tue, 10 Nov 2020 22:21:01 +0000 (UTC) X-Spam-Summary: 1,0,0,c3a7cc29e404982e,d41d8cd98f00b204,3sxkrxwokcca6j9naugjrhckkcha.8kihejqt-iigr68g.knc@flex--andreyknvl.bounces.google.com,,RULES_HIT:41:69:152:355:379:541:800:960:965:966:967:968:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1534:1541: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:3352:3865:3867:3868:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4385:4390:4395:4425:5007:6119:6261:6653:6742:7903:8957:9025:9592:9969:10004:10400:11026:11473:11658:11914:12043:12297:12438:12555:12679:12895:12986:13069:13311:13357:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:21939:21990:30054:30070,0,RBL:209.85.222.201:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yr5ekij3444aepxy8893pn5bgrjypkzdbb3zmfkkkmdmn941amb5zamrqhb3y.ouqxubqdwy3r3x4uiojz3p5ersoprp4r347wam9 oidd6ggw X-HE-Tag: nail72_5302286272f8 X-Filterd-Recvd-Size: 4592 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 22:21:00 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id x85so200414qka.14 for ; Tue, 10 Nov 2020 14:21:00 -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=JVfCx5YoVAhsMAMzq5Ib4xNDNXTPugCAXEdF/9ZfK1c=; b=Sorzbxjl434teafjW3faZG7zFZzfm93UE5ni1XpfIncUp10ibp8jpLYD70flrD0+2/ /ZaY5ksYh6XtmAQzE15CeAKLXWStbYLxHdCNnUebaCqUpyj9z4JlZq4J3u8IfE10A5Lq Zr3qjbG+frRqzlU2wYjRNGXaopuLOQnurA51QAgFYIIrikpen/tETHXDcodSPHKR/9By HM+aXQXai3muVVFES7+dvfTZwk3Q1hnpbedVcj8nRXP8nq6OW22Mr8dJd3a/ILVJSdD3 So1MJMa8xAODLMxUsWoHgul0P/PCAhB0ZKwHZbNh8Nu2VglU+Jp9Lss9YGFtCDcHEgIE Xc4w== 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=JVfCx5YoVAhsMAMzq5Ib4xNDNXTPugCAXEdF/9ZfK1c=; b=Z93qo6PM7pEhFd/BkuQkO3+d9tSfWGwDSZwPLa7SSL0TM73j3DUWYJRL17sHbIKXnw JBZUjGQaLNbNFuTxltFqdKKuNlmZuHIqh7Cz5YUxG+CdJ0twmcWR2X+FAZ8QN+Po7Nw1 lli1ioFPp/hv3f0DpgqI0sjupvemKqeHPA+nZAFwphF+2h64KdwI+zutS4cxDa1O/QK2 od/+3PODSJB3EMz0lO8R5oJeXOOEfI501bsM1UQH+KgWlsavX/Y37ToZ2mO5STjszy6L GrAoiW3Mcvpy/ymiDEHOlDbm8Ouq83iZT5nDwATaDO/ozBQXbNSpJri7k4UnkG8UrAOT ahjA== X-Gm-Message-State: AOAM531a7AEF8Roj+Nzmom+Pj7mMbg4JHy2CKIuVzq/Lyz7nis5XskKt HKgyaws1lQM2rWdvFXWXCnfuMxyjMCtlNScZ X-Google-Smtp-Source: ABdhPJz9X4I0fQKQ6rAPw02HsIflV/nkdacrsdfDSd0mERCmB5vYjtdDNjyd6StrpyBIrGYzVfJD2gDIvmTN5dGg X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a0c:e790:: with SMTP id x16mr12244792qvn.21.1605046859712; Tue, 10 Nov 2020 14:20:59 -0800 (PST) Date: Tue, 10 Nov 2020 23:20:17 +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 13/20] kasan: simplify 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: kasan_poison_kfree() is currently only called for mempool allocations that are backed by either kmem_cache_alloc() or kmalloc(). Therefore, the page passed to kasan_poison_kfree() is always PageSlab() and there's no need to do the check. Remove it. Signed-off-by: Andrey Konovalov Reviewed-by: Dmitry Vyukov Link: https://linux-review.googlesource.com/id/If31f88726745da8744c6bea96fb32584e6c2778c Reviewed-by: Marco Elver --- mm/kasan/common.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 385863eaec2c..819403548f2e 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -432,16 +432,7 @@ void __kasan_poison_kfree(void *ptr, unsigned long ip) struct page *page; page = virt_to_head_page(ptr); - - if (unlikely(!PageSlab(page))) { - if (ptr != page_address(page)) { - kasan_report_invalid_free(ptr, ip); - return; - } - kasan_poison_memory(ptr, page_size(page), KASAN_FREE_PAGE); - } else { - ____kasan_slab_free(page->slab_cache, ptr, ip, false); - } + ____kasan_slab_free(page->slab_cache, ptr, ip, false); } void __kasan_kfree_large(void *ptr, unsigned long ip)