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: 11895853 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 9329CC388F7 for ; Tue, 10 Nov 2020 23:47:32 +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 3CFB1207E8 for ; Tue, 10 Nov 2020 23:47:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EftlDDcA"; 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 3CFB1207E8 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=uiJ6yo17oEWh2D6WQGw+UTz4Bza9/Qxdp5ZGLuzPtYA=; b=EftlDDcAJ7SCOw2MtdI1jAs1X fbwrv2nM6ljZRMfXLhIKNX69uwTqP2gvSadF7wz31b8CNoRIPEmr4rbzRGKFKEKoHVRFiyvXUPZJ+ 15rSvoFwujL/dVWXipu0yDwa4+g53PijoEwjUehPqAud8kzy5l9gqMRZzE+ASR7ZTrY3QA2EQYXzy 1p14INZ1yjEEt9dEw33zfdaGgxCHn9Ihb9whNWsu0USDeqxHZ//0GC8SW0ZmgS5NrWOki6N1ykvxx FsrUuCfeGnxBwM9/fbOkl8E2Hh3C+tesl6oplHC6F3rxvaw8xuOI/ICR7jctdTZBCW6B7eQXvVPPu StmrQboUA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcdLV-0002cp-VN; Tue, 10 Nov 2020 23:46:41 +0000 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcc0h-0000Qj-2x for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 22:21:29 +0000 Received: by mail-qt1-x84a.google.com with SMTP id o1so2160623qtp.7 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=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=meT2OUChPWwAVOvnXWP2fiYwDd6ugVlSm0d1Rv3uzueV0gIEjxfNG/o9So67cwFYhM b1aa7eS4AwR5tgTYJmoyFzl1/LejCb5uuCoP3rnRkTk4hfUZRsJF7PUrQBDgJF0+PRsf DPwpM0nV5wNB3lzv+4BouKx8LlWeEXLYMboRsXbZjg92q1zxusJS4PytcAXck7JFlBpu 6vyiHN+/XdMNYlxP/Z/mnsOD7tAhot2p80MIM7mkK4FR+/ND+WuVE9tfdyh67B+HnzkI b3o/rjs9JWUtZr1qX5SxrJWOBtHMvuDoFw6GZ3WxLY4FCJ48piPzVnXcT+dbqaKUyimH r3Dg== X-Gm-Message-State: AOAM532LRGmDI53+kahYHR2udA+boowGwt7bWHrH+WEEiM/mzWRwzsEU qotqNvtbFy308QjU9FryQcjqfC8LP939WO1J 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_172108_335668_080DCA86 X-CRM114-Status: GOOD ( 13.41 ) 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 , Catalin Marinas , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Konovalov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , 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 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)