From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 4/2] mkfs: don't crash on dswidth overflow
Date: Mon, 29 Jan 2018 19:38:30 -0800 [thread overview]
Message-ID: <20180130033830.GL9068@magnolia> (raw)
In-Reply-To: <151692412532.32390.5360363880930671862.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
I ran mkfs.xfs -d su=1048576,sw=$((18 * 1048576)), forgetting that sw
takes a multiple of su (unlike swidth which takes any space unit). I
was surprised when we hit a floating point exception, which I traced
back to an integer overflow when we calculate swidth from dsw.
So, do the 64-bit multiplication so we can detect the overflow and
complain about it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
mkfs/xfs_mkfs.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 5f1ac9f..7c9d148 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2211,6 +2211,7 @@ calc_stripe_factors(
struct cli_params *cli,
struct fs_topology *ft)
{
+ long long int big_dswidth;
int dsunit = 0;
int dswidth = 0;
int lsunit = 0;
@@ -2251,7 +2252,14 @@ _("data su must be a multiple of the sector size (%d)\n"), cfg->sectorsize);
}
dsunit = (int)BTOBBT(dsu);
- dswidth = dsunit * dsw;
+ big_dswidth = (long long int)dsunit * dsw;
+ if (big_dswidth > INT_MAX) {
+ fprintf(stderr,
+_("data stripe width (%lld) is too large of a multiple of the data stripe unit (%d)\n"),
+ big_dswidth, dsunit);
+ usage();
+ }
+ dswidth = big_dswidth;
}
if (dsunit && (dswidth % dsunit != 0)) {
next prev parent reply other threads:[~2018-01-30 3:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 23:48 [PATCH 0/2] xfsprogs: 4.15 rollup pt. 3 Darrick J. Wong
2018-01-25 23:48 ` [PATCH 1/2] xfs_db: print transaction reservation type information Darrick J. Wong
2018-01-25 23:48 ` [PATCH 2/2] xfs_db: interpret inode timestamps as signed integers Darrick J. Wong
2018-01-30 16:46 ` Eric Sandeen
2018-01-26 18:14 ` [PATCH 3/2] misc: ubsan fixes Darrick J. Wong
2018-01-30 16:47 ` Eric Sandeen
2018-01-30 3:38 ` Darrick J. Wong [this message]
2018-01-30 3:54 ` [PATCH 4/2] mkfs: don't crash on dswidth overflow Eric Sandeen
2018-01-30 3:38 ` [PATCH 5/2] mkfs: don't call values 'illegal', they're invalid Darrick J. Wong
2018-01-30 3:55 ` Eric Sandeen
2018-01-30 3:39 ` [PATCH 6/2] mkfs: always explain why numeric inputs are invalid Darrick J. Wong
2018-01-30 3:57 ` Eric Sandeen
2018-01-30 4:13 ` [PATCH 7/2] mkfs: more sunit/swidth sanity checking Eric Sandeen
2018-01-30 16:48 ` Darrick J. Wong
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=20180130033830.GL9068@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).