Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2375580rdf; Mon, 6 Nov 2023 12:12:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH01pawIQY6wDcRCwRMNUvZdBPa0bAn/4KytPvQJnQBgKevt6i7zhY24Oo6wO/6Y5WjF3U3 X-Received: by 2002:a17:90b:4f4e:b0:280:959d:1d10 with SMTP id pj14-20020a17090b4f4e00b00280959d1d10mr15435840pjb.3.1699301552701; Mon, 06 Nov 2023 12:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301552; cv=none; d=google.com; s=arc-20160816; b=iQ00xXMLzWc0yXP2FPIs8jMXOHhOWDBqdwq4Ut7ROejTPTespuqVRupOv+Z8U0JBM2 +2qntdZ0R5e3NaHWjz0fIF2ztYqdBntlIb24Q26XMmujit/bKccpwXx58HIPSagxKgeY z/J3iLVg8Ztxj06eRSZ/ZPjO1NndXje9RGdvezJzeHaTuAdvb7ttVZptUdUYpQqsUE4c 2diaX99bJhx3Veu2PTY5M8OfjS1KXYq59O2BBnroObHJuIC2S/bU90Tl6CWArOEfOwRX DR85AmPQnsQIb3OauB3TwGx98iHwCb+ZIIUGIxyoR9qm7ePPRC/fPgQtM0XNamxG1MSG 8F7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XVuFmnWl7Ai+GOwJv1yuDcJd9SrRUciNhjDptmGZnZI=; fh=n5KN85tQTomq0Sa/nFFC9xbnc77mxkBzF8HoolO/QOw=; b=iZ9/QislLjNyzd5PQwaeW7FgK7VOxWJVF9V9/CNPbjSL2FoUCGruk4xq0nNfu+97dM 3/ROWrrhm0Pc7vkr7IrgyvadfbpUDBPHXYUedwOC0BGjxFx+hx4OalRyP4v+eYT5vNU1 Gx1fUM+XMXiPYxUgjbtTo+Rn29oPJZMagDdPp3zF/0FLyXvc6/vIgjqy7qVBpEKxay61 rY5mdzXwSezpeavVbMfRkjdwUjQdszuxBO0i/sQuJ4dn+JVlOdqhDTnxHYDzLuvhx5IU gakwn88DGjuACwnPS0YqFvz4PZNbaQNCao3y8uqalqiq97Oo78POp0jo4TmyYMMaqTvu ASGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vvDAFFN6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id gq18-20020a17090b105200b00280435c5051si8519715pjb.174.2023.11.06.12.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vvDAFFN6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0DADE8032A2C; Mon, 6 Nov 2023 12:12:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233022AbjKFULx (ORCPT + 99 others); Mon, 6 Nov 2023 15:11:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232940AbjKFULp (ORCPT ); Mon, 6 Nov 2023 15:11:45 -0500 Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [IPv6:2001:41d0:203:375::b8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B10210C9 for ; Mon, 6 Nov 2023 12:11:41 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1699301499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XVuFmnWl7Ai+GOwJv1yuDcJd9SrRUciNhjDptmGZnZI=; b=vvDAFFN6FcYKWYAGx5sCoYZo2aE996ZHT27ORsBGzAXwAllc9a/mweQGGLH+tNqC9ukgoo kfT6X1bqAgw8fHV/cuj8owqV2YMiINk9I1HHRRwNCkZiOyFphUoExea/Wc88Wdh/Xw3yFD ieHf70kObAwysIDH+u5fgJoaxYfbcAM= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH RFC 08/20] kasan: clean up __kasan_mempool_poison_object Date: Mon, 6 Nov 2023 21:10:17 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:12:30 -0800 (PST) From: Andrey Konovalov Reorganize the code and reword the comment in __kasan_mempool_poison_object to improve the code readability. Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 6283f0206ef6..7c28d0a5af2c 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -447,27 +447,22 @@ void __kasan_mempool_unpoison_pages(struct page *page, unsigned int order, bool __kasan_mempool_poison_object(void *ptr, unsigned long ip) { - struct folio *folio; - - folio = virt_to_folio(ptr); + struct folio *folio = virt_to_folio(ptr); + struct slab *slab; /* - * Even though this function is only called for kmem_cache_alloc and - * kmalloc backed mempool allocations, those allocations can still be - * !PageSlab() when the size provided to kmalloc is larger than - * KMALLOC_MAX_SIZE, and kmalloc falls back onto page_alloc. + * This function can be called for large kmalloc allocation that get + * their memory from page_alloc. Thus, the folio might not be a slab. */ if (unlikely(!folio_test_slab(folio))) { if (check_page_allocation(ptr, ip)) return false; kasan_poison(ptr, folio_size(folio), KASAN_PAGE_FREE, false); return true; - } else { - struct slab *slab = folio_slab(folio); - - return !____kasan_slab_free(slab->slab_cache, ptr, ip, - false, false); } + + slab = folio_slab(folio); + return !____kasan_slab_free(slab->slab_cache, ptr, ip, false, false); } void __kasan_mempool_unpoison_object(void *ptr, size_t size, unsigned long ip) -- 2.25.1