public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: An Long <lan@suse.com>
To: fstests@vger.kernel.org
Cc: An Long <lan@suse.com>
Subject: [PATCH] common/config: Fix use of MKFS_OPTIONS
Date: Fri, 24 Jun 2022 00:08:25 +0800	[thread overview]
Message-ID: <20220623160825.31788-1-lan@suse.com> (raw)

_scratch_mkfs_sized() only receive integer number of bytes as a valid
input. But if the MKFS_OPTIONS variable exists, it will use the value of
block size in MKFS_OPTIONS to override input. In case of
MKFS_OPTIONS="-b 4k", would result in blocksize=4 but not 4096. This
will give errors to ext2/3/4 etc, and brings potential bugs to xfs or
btrfs.

Therefore, add validation check to force MKFS_OPTIONS to use pure
integer in bytes for any size value.

Signed-off-by: An Long <lan@suse.com>
---
 README        | 3 ++-
 common/config | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/README b/README
index 80d148be..7c2d3334 100644
--- a/README
+++ b/README
@@ -241,7 +241,8 @@ Misc:
    this option is supported for all filesystems currently only -overlay is
    expected to run without issues. For other filesystems additional patches
    and fixes to the test suite might be needed.
-
+ - If MKFS_OPTIONS is used, the size value must be an integer number of bytes
+   without units. For example, set MKFS_OPTIONS="-b 4096" but not "-b 4k".
 ______________________
 USING THE FSQA SUITE
 ______________________
diff --git a/common/config b/common/config
index de3aba15..ec723ac4 100644
--- a/common/config
+++ b/common/config
@@ -896,5 +896,10 @@ else
 	fi
 fi
 
+# check the size value in $MKFS_OPTIONS is an integer
+if [[ $MKFS_OPTIONS =~ [0-9]+[^0-9\ ] ]] ; then
+        _fatal "error: \$MKFS_OPTIONS: Only number in bytes is allowed, no units."
+fi
+
 # make sure this script returns success
 /bin/true
-- 
2.35.3


             reply	other threads:[~2022-06-23 16:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 16:08 An Long [this message]
2022-06-23 18:17 ` [PATCH] common/config: Fix use of MKFS_OPTIONS Darrick J. Wong
2022-06-24  2:14   ` Zorro Lang
2022-06-24  2:41   ` Dave Chinner
2022-06-24  3:29     ` Long An
2022-06-25  3:15       ` Darrick J. Wong
2022-06-25 16:38         ` Zorro Lang
2022-06-25 16:39 ` Theodore Ts'o
2022-06-25 22:47   ` Dave Chinner
2022-06-26  2:09     ` Theodore Ts'o

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=20220623160825.31788-1-lan@suse.com \
    --to=lan@suse.com \
    --cc=fstests@vger.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