From patchwork Thu Dec 21 20:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 182442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp660312dyi; Thu, 21 Dec 2023 12:07:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKDMXcfwAukeXRAhLYszFUMB2EBEaAABTc9DA9qwsl97/2XowsA4KW3GSp4uLyGVydyVLw X-Received: by 2002:a05:6a20:6d90:b0:194:c6d3:1bdd with SMTP id gl16-20020a056a206d9000b00194c6d31bddmr201360pzb.124.1703189271856; Thu, 21 Dec 2023 12:07:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703189271; cv=none; d=google.com; s=arc-20160816; b=U3Vj61f3C4R7DhuG3LVR16ykEpTy44lWAIQCc1dsatT8TNhmwPomcmpaGjg8KXeGG2 dQK2TmxmThSlKZwv4Bl3rYNaEmC2S/u0ZfN8d7bZ8iBnIXtRJm+ENBatIF/w+Wv+xXD4 GyMpCNifR83TAw/9Sk4BZbI4SyuPDmI0CwXXNZqcq/U7uS0BJ16nMbktmnyROcrP2w8Z 4XYukugbgukrFcMX8gQxObog9rP4HNnvftipWPtTUAHEds/gtrSYKy1SYSzf2X2N62iD Vb9TehzTllBHG1k5/eSjlcw3TcMfsEq24mkCJNUqwhg5TkJJmiFIqq3EGJWkxSc/QHom /EXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=itOhYdVtqZdvAR7o0Q16gEQdZUJ+zDuxto8wg6YMX5U=; fh=GyTEpUCUNPwsl1pqA0jDPXgvja+iZTM9USlQd9sQtQg=; b=IyswgQyoEfa5NMG9KGOslRN1bMzhX03Sx2cbigM2tIHT5d0FQ0WHwYR1Oz8sRFntQP ghzpDZs/JL86Lfu/AjaVcmQJ9L0fHV0gPhnsmNOtgL8xCwwSB0hUw4TPQKkkh0gfGhU4 ncDSN3PX2KyZ9LCQfj3CkOHncBNQbyqwwwLR2mhYoRwVSF+4MiNCW2VsApA1Witzjwj1 sIYLHzSrD4PruqEwo4doYltAbeLrn1MZenkKVoD4DNVJ2kGSOEtMRWnWDcQ7sCUIxxec TWncn3ZRsiSn5GtjtqQeF39A/1EXNmLyjIeuYtNWaLmo57at4HI/W2pRdaAxHnfIHQfj 3L+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KmqU694Z; spf=pass (google.com: domain of linux-kernel+bounces-9028-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u18-20020aa78392000000b006d9663aaba5si2021535pfm.33.2023.12.21.12.07.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 12:07:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9028-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KmqU694Z; spf=pass (google.com: domain of linux-kernel+bounces-9028-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2EEA4288D1B for ; Thu, 21 Dec 2023 20:07:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29A6A77F05; Thu, 21 Dec 2023 20:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="KmqU694Z" X-Original-To: linux-kernel@vger.kernel.org Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D79C2745E9 for ; Thu, 21 Dec 2023 20:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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=1703189167; 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=itOhYdVtqZdvAR7o0Q16gEQdZUJ+zDuxto8wg6YMX5U=; b=KmqU694Zt6wu9nrYTkctmmkfBJq7NuWGLfuL6LQc4yRHrVvgSk9TrEaIkENsIsxAhzy0iD M5jyxL69O1qWaiZjFMO8J3Kk4OIyyumpmCcqjeJvbednSEB0sn4BUCn5787rVS16/+WTWn vHxsZcIZaRd0Vg3+r7Go8wBuNHm2nL0= From: andrey.konovalov@linux.dev To: Marco Elver Cc: Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 10/11] kasan: remove SLUB checks for page_alloc fallbacks in tests Date: Thu, 21 Dec 2023 21:04:52 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785923394143326043 X-GMAIL-MSGID: 1785923394143326043 From: Andrey Konovalov A number of KASAN tests rely on the fact that calling kmalloc with a size larger than an order-1 page falls back onto page_alloc. This fallback was originally only implemented for SLUB, but since commit d6a71648dbc0 ("mm/slab: kmalloc: pass requests larger than order-1 page to page allocator"), it is also implemented for SLAB. Thus, drop the SLUB checks from the tests. Signed-off-by: Andrey Konovalov --- mm/kasan/kasan_test.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c index 496154e38965..798df4983858 100644 --- a/mm/kasan/kasan_test.c +++ b/mm/kasan/kasan_test.c @@ -215,7 +215,7 @@ static void kmalloc_node_oob_right(struct kunit *test) /* * Check that KASAN detects an out-of-bounds access for a big object allocated - * via kmalloc(). But not as big as to trigger the page_alloc fallback for SLUB. + * via kmalloc(). But not as big as to trigger the page_alloc fallback. */ static void kmalloc_big_oob_right(struct kunit *test) { @@ -233,8 +233,7 @@ static void kmalloc_big_oob_right(struct kunit *test) /* * The kmalloc_large_* tests below use kmalloc() to allocate a memory chunk * that does not fit into the largest slab cache and therefore is allocated via - * the page_alloc fallback for SLUB. SLAB has no such fallback, and thus these - * tests are not supported for it. + * the page_alloc fallback. */ static void kmalloc_large_oob_right(struct kunit *test) @@ -242,8 +241,6 @@ static void kmalloc_large_oob_right(struct kunit *test) char *ptr; size_t size = KMALLOC_MAX_CACHE_SIZE + 10; - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); @@ -258,8 +255,6 @@ static void kmalloc_large_uaf(struct kunit *test) char *ptr; size_t size = KMALLOC_MAX_CACHE_SIZE + 10; - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); kfree(ptr); @@ -272,8 +267,6 @@ static void kmalloc_large_invalid_free(struct kunit *test) char *ptr; size_t size = KMALLOC_MAX_CACHE_SIZE + 10; - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); @@ -407,18 +400,12 @@ static void krealloc_less_oob(struct kunit *test) static void krealloc_large_more_oob(struct kunit *test) { - /* page_alloc fallback is only implemented for SLUB. */ - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - krealloc_more_oob_helper(test, KMALLOC_MAX_CACHE_SIZE + 201, KMALLOC_MAX_CACHE_SIZE + 235); } static void krealloc_large_less_oob(struct kunit *test) { - /* page_alloc fallback is only implemented for SLUB. */ - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - krealloc_less_oob_helper(test, KMALLOC_MAX_CACHE_SIZE + 235, KMALLOC_MAX_CACHE_SIZE + 201); } @@ -1144,9 +1131,6 @@ static void mempool_kmalloc_large_uaf(struct kunit *test) size_t size = KMALLOC_MAX_CACHE_SIZE + 1; void *extra_elem; - /* page_alloc fallback is only implemented for SLUB. */ - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - extra_elem = mempool_prepare_kmalloc(test, &pool, size); mempool_uaf_helper(test, &pool, false); @@ -1215,9 +1199,6 @@ static void mempool_kmalloc_large_double_free(struct kunit *test) size_t size = KMALLOC_MAX_CACHE_SIZE + 1; char *extra_elem; - /* page_alloc fallback is only implemented for SLUB. */ - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - extra_elem = mempool_prepare_kmalloc(test, &pool, size); mempool_double_free_helper(test, &pool); @@ -1272,9 +1253,6 @@ static void mempool_kmalloc_large_invalid_free(struct kunit *test) size_t size = KMALLOC_MAX_CACHE_SIZE + 1; char *extra_elem; - /* page_alloc fallback is only implemented for SLUB. */ - KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); - extra_elem = mempool_prepare_kmalloc(test, &pool, size); mempool_kmalloc_invalid_free_helper(test, &pool);