Message ID | tencent_F56949906EED6EC90C8027D0C6DFD2F84606@qq.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | jfs: check agwidth before calculating the control page level | expand |
Catching up on long-ignored emails. On 12/3/24 4:22AM, Edward Adam Davis via Jfs-discussion wrote: > The width in dmapctl of the AG is zero, it trigger a divide error when > calculating the control page level in dbAllocAG. > > To avoid this issue, add a check for agwidth in dbAllocAG. This value shouldn't change unless the filesystem is resized. I would prefer that the check was made once in dbMount(). Shaggy > > Reported-and-tested-by: syzbot+7c808908291a569281a9@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=7c808908291a569281a9 > Signed-off-by: Edward Adam Davis <eadavis@qq.com> > --- > fs/jfs/jfs_dmap.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c > index f9009e4f9ffd..2377102d9c4c 100644 > --- a/fs/jfs/jfs_dmap.c > +++ b/fs/jfs/jfs_dmap.c > @@ -1373,6 +1373,11 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results) > return (rc); > } > > + if (!bmp->db_agwidth) { > + jfs_error(bmp->db_ipbmap->i_sb, "width in dmapctl of the AG is zero\n"); > + return -EIO; > + } > + > /* the buffer for the dmap control page that fully describes the > * allocation group. > */
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index f9009e4f9ffd..2377102d9c4c 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -1373,6 +1373,11 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results) return (rc); } + if (!bmp->db_agwidth) { + jfs_error(bmp->db_ipbmap->i_sb, "width in dmapctl of the AG is zero\n"); + return -EIO; + } + /* the buffer for the dmap control page that fully describes the * allocation group. */
The width in dmapctl of the AG is zero, it trigger a divide error when calculating the control page level in dbAllocAG. To avoid this issue, add a check for agwidth in dbAllocAG. Reported-and-tested-by: syzbot+7c808908291a569281a9@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=7c808908291a569281a9 Signed-off-by: Edward Adam Davis <eadavis@qq.com> --- fs/jfs/jfs_dmap.c | 5 +++++ 1 file changed, 5 insertions(+)