mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] initramfs_test: exercise the oversized CPIO namesize guard
@ 2026-10-27  8:51 Avi Weiss
  0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-10-27  8:51 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner
  Cc: Jan Kara, David Disseldorp, linux-fsdevel, linux-kernel, Avi Weiss

initramfs_test_fname_path_max() uses a directory with a nonzero body.
Such entries are skipped even without the namesize > PATH_MAX check,
so the test does not detect removal of that check.

Use a regular file and terminate the archived pathname early after
fill_cpio() has encoded the oversized namesize. This allows the test
to detect a missing parser check without relying on VFS pathname
length limits.

Fixes: aaf76839616a ("initramfs_test: kunit test for cpio.filesize > PATH_MAX")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 init/initramfs_test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/init/initramfs_test.c b/init/initramfs_test.c
index 1154547721ea..32d4d3e4e6c7 100644
--- a/init/initramfs_test.c
+++ b/init/initramfs_test.c
@@ -474,7 +474,7 @@ static void __init initramfs_test_fname_path_max(struct kunit *test)
 	struct initramfs_test_cpio c[] = { {
 		.magic = "070701",
 		.ino = 1,
-		.mode = S_IFDIR | 0777,
+		.mode = S_IFREG | 0777,
 		.nlink = 1,
 		.namesize = sizeof(tbufs->fname_oversize),
 		.fname = tbufs->fname_oversize,
@@ -495,6 +495,8 @@ static void __init initramfs_test_fname_path_max(struct kunit *test)
 	       sizeof("fname_oversize") - 1);
 	memcpy(tbufs->fname_ok, "fname_ok", sizeof("fname_ok") - 1);
 	len = fill_cpio(c, ARRAY_SIZE(c), false, tbufs->cpio_src);
+	/* keep namesize oversized, but give VFS a short pathname */
+	tbufs->cpio_src[CPIO_HDRLEN + sizeof("fname_oversize") - 1] = '\0';
 
 	/* unpack skips over fname_oversize instead of returning an error */
 	err = unpack_to_rootfs(tbufs->cpio_src, len);

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-27  8:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27  8:51 [PATCH] initramfs_test: exercise the oversized CPIO namesize guard Avi Weiss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®