From patchwork Thu Nov 5 00:02:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11883045 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 25E0BC00A89 for ; Thu, 5 Nov 2020 03:38:05 +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 9DEBD2072E for ; Thu, 5 Nov 2020 03:38:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EPuXzTTU"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pdY+e1OM"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="U8jhak8M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DEBD2072E 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=8guCawMFq4d5/5f4Z58iyQPrhBv2NM5OVWtDIr6F0oQ=; b=EPuXzTTUTxu7RtP/NxkGat7pt lghizcDEFVv1YJNSqCrOZxzr+9mq2RIEFy+un2Fp6FBpbEzVC9TkPV/pUiqCJ33G66PpTWlZSC/Ry 4TaDSUZiG9/qb0693XCyngTFKROdjOyorUiCz/IHcXF7DgXQz06R9i70BWYNbVEqexOqhqb4uy9wm 2jYo59PHAMPtgLGqMiKA25Y7K5zUSsHSmDX2gSgCKe8njPHvaKCZfATRYmyKe9fQxK2bwHVszV/wt L6mz3H9niunnLWYBBrW2SISAFdsJMDBHCxR+FywFbme5IicNfePUuK8o4QK8kqjQd+lMOekIm4a9X osBsd9hLQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaW4t-0001zb-CP; Thu, 05 Nov 2020 03:36:47 +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-000145-LO 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=BMZ/M+WrZmZXK8ABsLpLLUMO5suYjkxoKy6+yIMHKNI=; b=pdY+e1OMG/PxvUQ/iiFSUY4YTK smkVYR70ioqjneFMPc9A9ay5u0HVbKgc8opSaSzblrZ7Ta0eou8ZuqmNzcamGDHxaur3B2f1sAK3m esQrhL7ymPvqkX1NFdgXENV0EXW3IpOOocWRPtuUT+zO8iT3TA1d4y5CS5vU/sGRL1lQwKHBuHkDG NAIG/j2InPFHWO/Dwst4Hg08RFTc6iAOqKPMrkA6ul7483zEsYubpZcuMu8bZxgvH8IwVofQD5ypF hh4d9T0NSojTP+R/sG/rqJiCA9nucMSjrRJLDwq8SnVA8EfShEwLDfAFsxw7SmVSwMptI45ec51fA WZb9/nSg==; Received: from mail-ej1-x64a.google.com ([2a00:1450:4864:20::64a]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaSl8-0000rV-4I for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2020 00:04:13 +0000 Received: by mail-ej1-x64a.google.com with SMTP id nt22so92186ejb.17 for ; Wed, 04 Nov 2020 16:04:09 -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=BMZ/M+WrZmZXK8ABsLpLLUMO5suYjkxoKy6+yIMHKNI=; b=U8jhak8MkkwTo4VVA2S4aMMc3rysJoG7VHeplDyb4fXuf1THbqycXNlTuCEhZq1ndK AhCyWSIEEOYjSrqyLHpxcdGv3yzV87WfK1+ghuNzSnULiKfdJVOxe6sUUQd7sxT+81Pm 6XhrLx6kwXsOktWPr/cM0ZinyJvTm5jvezSnFF3iKwjECgARv++K8S8XZ4/9MBv984h3 M3fq09VNCB+Bg+9rcUoAMcvxXA54/qhwAgrNEF7lkW3u5fOaa5RoV0kgdWx3fxww+s6M Ria7FGAAeatBPhxai7ZCgPgRfE1vFFHs7XGihw6Ux0UtxsTqIWhVPGuecdGyuf1tCe/W JiOg== 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=BMZ/M+WrZmZXK8ABsLpLLUMO5suYjkxoKy6+yIMHKNI=; b=s22s2DAIFMSNhVgz++GZw6NX1BI6gBSkDdQGTOWd0nMGZ7u4AA+doyfp88R2PnQ3Vr ztH9ParNFmEJ2pnmsVyUwdpbWoJb//zTFYMqLL+N7GFohzA79AwLrk8Vd8uVv2JhB4To rGwlHyHvZFGW/9Bi2hAp/LzbDa8wMtA+j6zs0tWxbO/fb0eMO95bR+tAxd5uxlH+lPvf 6TD7wAB7N/lJFIGoOsf0fbxM6j1KyMTqSa91JCSj1m8PGedvGrFqbwUgNBhmh/mcXMbj k+e8jFR4sBHiJx0NutAmqKUUCY5lGHvT+6hmIQAqyDV5UyI+syI/yXQHiz2xglnv7Ydu Ekkg== X-Gm-Message-State: AOAM531W3fCh9kYTuNv73oDaRP+WBJpOqfapqKy9jqWEYesrHLdoeJgI Cy7sCIDjta3uH3amNYRYJD128d1AHHwi+nKH X-Google-Smtp-Source: ABdhPJweTaJkd6b3wl4vljsjzSaHEeYVHgfBL2uu8wiqY4d4DlmNQcw7W5IBJIWQpkZx+af/OCfJ+MPWnW+0Gr4h X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a17:906:134e:: with SMTP id x14mr575217ejb.173.1604534586349; Wed, 04 Nov 2020 16:03:06 -0800 (PST) Date: Thu, 5 Nov 2020 01:02:23 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 13/20] kasan: simplify 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_307869_F3542FE2 X-CRM114-Status: GOOD ( 11.05 ) 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 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 --- 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)