diff mbox series

xfs: fix SIGFPE bug in align_ag_geometry

Message ID 61b82c3c-5bcf-0c91-4fa5-fa138b52a6a6@huawei.com (mailing list archive)
State New, archived
Headers show
Series xfs: fix SIGFPE bug in align_ag_geometry | expand

Commit Message

Li Xiao Keng April 1, 2021, 1:58 a.m. UTC
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(+)

--

Comments

Gao Xiang April 1, 2021, 2:29 a.m. UTC | #1
On Thu, Apr 01, 2021 at 09:58:53AM +0800, lixiaokeng wrote:
> 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.
> 

May I ask what's the command line? and is it reproducable on
the latest upstream version?

Thanks,
Gao Xiang

> 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) {
> -- 
>
Gao Xiang April 1, 2021, 2:53 a.m. UTC | #2
On Thu, Apr 01, 2021 at 10:29:15AM +0800, Gao Xiang wrote:
> On Thu, Apr 01, 2021 at 09:58:53AM +0800, lixiaokeng wrote:
> > 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.
> > 
> 
> May I ask what's the command line? and is it reproducable on
> the latest upstream version?

Btw, according to the line number of your patch format, it seems
your patch was based on "v4.17.0". May I ask which version you
were testing? If so, that is an outdated version, it'd be better
to try with latest version first.

Thanks,
Gao Xiang

> 
> Thanks,
> Gao Xiang
> 
> > 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) {
> > -- 
> >
diff mbox series

Patch

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) {