From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) (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 E5E573246E8 for ; Thu, 26 Mar 2026 21:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.10.14.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774561810; cv=none; b=RZhVkluFcV4bz5eNC12EZL6ev2au8/5AQuLtB39429iuwjXNPbZgo7L0qRQSJabIm3aiR6EGZT5hHvjgglQMyAVuBNLKFN0TyMr1d7cqZ/q64nqFDCX6Efr3FA3qx1B99gpIBsArfcfs3Qur4KrzeXprVMZfq1cSIhHJFQF6/2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774561810; c=relaxed/simple; bh=vkGW6xKDaw9eBT3dKHpPQ1oYcSujzKf44AiIkFp2+tw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=spamTDWHomVwkbVfRG3gLiIcqZXf7fb6/fshoCuuvV7cZ3UT1LJls1CxPpEXIefr0gvKXetody4T/IZA37FL/5ZE7tH1fvaYJtD1GhYLTp7wDoBmBUL1gunUoJGyebVCBEAmqF9b9t4/yBTltpn/HczCks2M2bewS+RSSd3vUEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de; spf=pass smtp.mailfrom=c--e.de; arc=none smtp.client-ip=217.10.14.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 97BA4140041; Thu, 26 Mar 2026 22:50:06 +0100 (CET) From: "Christian A. Ehrhardt" To: David Howells , Andrew Morton , linux-kernel@vger.kernel.org Cc: "Christian A. Ehrhardt" , Kees Cook , Petr Mladek , David Gow Subject: [PATCH v3 4/5] lib: kunit_iov_iter: Improve error detection Date: Thu, 26 Mar 2026 22:49:04 +0100 Message-Id: <20260326214905.818170-5-lk@c--e.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260326214905.818170-1-lk@c--e.de> References: <20260326214905.818170-1-lk@c--e.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In the kunit_iov_iter test prevent the kernel buffer from being a single physically contiguous region. Additionally, make sure that the test pattern written to a page in the buffer depends on the offset of the page within the buffer. Cc: David Howells Cc: Andrew Morton Signed-off-by: Christian A. Ehrhardt --- lib/tests/kunit_iov_iter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tests/kunit_iov_iter.c b/lib/tests/kunit_iov_iter.c index d16449bdb833..64a4e2f3eafa 100644 --- a/lib/tests/kunit_iov_iter.c +++ b/lib/tests/kunit_iov_iter.c @@ -13,6 +13,7 @@ #include #include #include +#include #include MODULE_DESCRIPTION("iov_iter testing"); @@ -37,7 +38,7 @@ static const struct kvec_test_range kvec_test_ranges[] = { static inline u8 pattern(unsigned long x) { - return x & 0xff; + return (u8)x + (u8)(x >> 8) + (u8)(x >> 16); } static void iov_kunit_unmap(void *data) @@ -52,6 +53,7 @@ static void *__init iov_kunit_create_buffer(struct kunit *test, struct page **pages; unsigned long got; void *buffer; + unsigned int i; pages = kzalloc_objs(struct page *, npages, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages); @@ -63,6 +65,9 @@ static void *__init iov_kunit_create_buffer(struct kunit *test, kvfree(pages); KUNIT_ASSERT_EQ(test, got, npages); } + /* Make sure that we don't get a physically contiguous buffer. */ + for (i = 0; i < npages / 4; ++i) + swap(pages[i], pages[i + npages / 2]); buffer = vmap(pages, npages, VM_MAP | VM_MAP_PUT_PAGES, PAGE_KERNEL); if (buffer == NULL) { -- 2.43.0