All of lore.kernel.org
 help / color / mirror / Atom feed
From: lixiaokeng <lixiaokeng@huawei.com>
To: <linux-xfs@vger.kernel.org>, <bfoster@redhat.com>,
	<sandeen@redhat.com>, <darrick.wong@oracle.com>
Cc: linfeilong <linfeilong@huawei.com>,
	"liuzhiqiang (I)" <liuzhiqiang26@huawei.com>
Subject: [PATCH] xfs: fix SIGFPE bug in align_ag_geometry
Date: Thu, 1 Apr 2021 09:58:53 +0800	[thread overview]
Message-ID: <61b82c3c-5bcf-0c91-4fa5-fa138b52a6a6@huawei.com> (raw)

In some case, the cfg->dsunit is 32, the cfg->dswidth is zero
and cfg->agsize is 6400 in align_ag_geometry. So, the
(cfg->agsize % cfg->dswidth) will lead to coredump.

Here add check cfg->dswidth. If it is zero, goto validate.

Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
---
 mkfs/xfs_mkfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index a135e06..71d3f74 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2725,6 +2725,9 @@ _("agsize rounded to %lld, sunit = %d\n"),
 				(long long)cfg->agsize, dsunit);
 	}

+	if (!cfg->dswidth)
+		goto validate;
+
 	if ((cfg->agsize % cfg->dswidth) == 0 &&
 	    cfg->dswidth != cfg->dsunit &&
 	    cfg->agcount > 1) {
-- 

             reply	other threads:[~2021-04-01  1:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01  1:58 lixiaokeng [this message]
2021-04-01  2:29 ` [PATCH] xfs: fix SIGFPE bug in align_ag_geometry Gao Xiang
2021-04-01  2:53   ` Gao Xiang

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=61b82c3c-5bcf-0c91-4fa5-fa138b52a6a6@huawei.com \
    --to=lixiaokeng@huawei.com \
    --cc=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.