Linux-f2fs-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 2/3] mkfs.f2fs: fix to limit length of main device path in f2fs_parse_options()
Date: Fri, 11 Jul 2025 15:45:50 +0800	[thread overview]
Message-ID: <20250711074551.216069-2-chao@kernel.org> (raw)
In-Reply-To: <20250711074551.216069-1-chao@kernel.org>

Otherwise, mkfs.f2fs may persist truncated path of main device.

- mkfs.f2fs /mnt/f2fs/0123456789012345678901234567890123456789012345678901234 \
  -c /mnt/f2fs/012345678901234567890123456789012345678901234567890123 -f
- mount /mnt/f2fs/0123456789012345678901234567890123456789012345678901234
  /mnt/f2fs/loop

F2FS-fs (loop0): Mount Device [ 0]: /mnt/f2fs/012345678901234567890123456789012345678901234567890123,      511,        0 -    3ffff
F2FS-fs (loop0): Failed to find devices

Signed-off-by: Chao Yu <chao@kernel.org>
---
 mkfs/f2fs_format_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 3a8fde0..f0bec4f 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -384,6 +384,12 @@ static void f2fs_parse_options(int argc, char *argv[])
 		mkfs_usage();
 	}
 
+	if (c.ndevs > 1 && strlen(argv[optind]) > MAX_PATH_LEN) {
+		MSG(0, "Error: main device path %s should be equal or "
+				"less than %d characters\n",
+				argv[optind], MAX_PATH_LEN);
+		mkfs_usage();
+	}
 	/* [0] : META, [1 to MAX_DEVICES - 1] : NODE/DATA */
 	c.devices[0].path = strdup(argv[optind]);
 
-- 
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2025-07-11  7:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11  7:45 [f2fs-dev] [PATCH 1/3] fsck.f2fs: allow to print more infos before assert() in init_sb_info() Chao Yu via Linux-f2fs-devel
2025-07-11  7:45 ` Chao Yu via Linux-f2fs-devel [this message]
2025-07-11  7:45 ` [f2fs-dev] [PATCH 3/3] fsck.f2fs: fix to use strncmp to avoid out-of-boundary access Chao Yu via Linux-f2fs-devel

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=20250711074551.216069-2-chao@kernel.org \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    /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