mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, David Disseldorp <ddiss@suse.de>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] initramfs_test: exercise the oversized CPIO namesize guard
Date: Tue, 27 Oct 2026 10:51:39 +0200	[thread overview]
Message-ID: <20261027085138.4107590-2-thnkslprpt@gmail.com> (raw)

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


                 reply	other threads:[~2026-10-27  8:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027085138.4107590-2-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=brauner@kernel.org \
    --cc=ddiss@suse.de \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®