mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+7c808908291a569281a9@syzkaller.appspotmail.com
Cc: axboe@kernel.dk, jfs-discussion@lists.sourceforge.net,
	kristian@klausen.dk, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, shaggy@kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: [PATCH] jfs: check agwidth before calculating the control page level
Date: Tue,  3 Dec 2024 18:22:00 +0800	[thread overview]
Message-ID: <tencent_F56949906EED6EC90C8027D0C6DFD2F84606@qq.com> (raw)
In-Reply-To: <674e82ce.050a0220.17bd51.0040.GAE@google.com>

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(+)

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.
 	 */
-- 
2.47.0


  parent reply	other threads:[~2024-12-03 10:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03  4:02 [syzbot] [jfs?] divide error in dbAllocAG syzbot
2024-12-03  7:56 ` Edward Adam Davis
2024-12-03  8:21   ` syzbot
2024-12-03  8:53 ` Edward Adam Davis
2024-12-03  9:24   ` syzbot
2024-12-03  9:47 ` Edward Adam Davis
2024-12-03 10:24   ` syzbot
2024-12-03 10:22 ` Edward Adam Davis [this message]
2025-02-19 21:20   ` [Jfs-discussion] [PATCH] jfs: check agwidth before calculating the control page level Dave Kleikamp
2025-02-20 11:24     ` [PATCH V2] jfs: add sanity check for agwidth in dbMount Edward Adam Davis
2025-02-20 16:21       ` Dave Kleikamp

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=tencent_F56949906EED6EC90C8027D0C6DFD2F84606@qq.com \
    --to=eadavis@qq.com \
    --cc=axboe@kernel.dk \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=kristian@klausen.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaggy@kernel.org \
    --cc=syzbot+7c808908291a569281a9@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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

all inboxes | Powered by JetHome®