From nobody Sun Apr 5 16:28:30 2026 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 DB8522ED17B for ; Tue, 24 Mar 2026 20:35:10 +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=1774384512; cv=none; b=UYJ55l27IlRW5WTz8fG+I1UX1PXOp3o8vEmw0ct34x0Ihkilm8hrqxc3A0t+PydemkY0XveNDqSg4aY9MAcO5xe0I6ggVA7fWB8izu4YFWEWlhvn6vd6xXqkJkhWKbDKBHgJL52gXjfntshp4fhHFT5nfmZXfuaWW3Cf1+apCeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774384512; c=relaxed/simple; bh=ClFjq4qysXJIYEcYDgHb639NolK9rw2GDJpagcruyCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rMTKX8JJRbxpq6A+szoca+W+JF2VLH2bzIsrh4ipXsTSBt1M+dF0gk7DJ2xSSTsDFvHphbT9w+nx0m1/BCbvmPJBwBLt67Wfl6vzEQFPb1OrBYC0cYgU3a8ih0n4GtTHomy3MmeOZ78jr4DL41ovqKaFwRZa+XMfsTkwbSXB25k= 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 83BB9140060; Tue, 24 Mar 2026 21:35:08 +0100 (CET) From: "Christian A. Ehrhardt" To: linux-kernel@vger.kernel.org, Andrew Morton , Josh Law , David Howells Cc: "Christian A. Ehrhardt" , Kees Cook , Petr Mladek , David Gow Subject: [PATCH v2 1/3] lib: kunit_iov_iter: Improve error detection Date: Tue, 24 Mar 2026 21:34:51 +0100 Message-Id: <20260324203453.810499-2-lk@c--e.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260324203453.810499-1-lk@c--e.de> References: <20260324203453.810499-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 bb847e5010eb..c42b9235f57a 100644 --- a/lib/tests/kunit_iov_iter.c +++ b/lib/tests/kunit_iov_iter.c @@ -13,6 +13,7 @@ #include #include #include +#include #include =20 MODULE_DESCRIPTION("iov_iter testing"); @@ -37,7 +38,7 @@ static const struct kvec_test_range kvec_test_ranges[] = =3D { =20 static inline u8 pattern(unsigned long x) { - return x & 0xff; + return (u8)x + (u8)(x >> 8) + (u8)(x >> 16); } =20 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; =20 pages =3D kunit_kcalloc(test, npages, sizeof(struct page *), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages); @@ -62,6 +64,9 @@ static void *__init iov_kunit_create_buffer(struct kunit = *test, release_pages(pages, got); KUNIT_ASSERT_EQ(test, got, npages); } + /* Make sure that we don't get a physically contiguous buffer. */ + for (i =3D 0; i < npages / 4; ++i) + swap(pages[i], pages[i + npages/2]); =20 buffer =3D vmap(pages, npages, VM_MAP | VM_MAP_PUT_PAGES, PAGE_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buffer); --=20 2.43.0