Skip to contentSkip to conversation

jfs: fix shift-out-of-bounds in dbSplit

PATCH In review Ghanshyam Agrawal 2 participants 2 messages Sep 30, 2024 – Oct 29, 2024 JFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jfs: fix shift-out-of-bounds in dbSplit

When dmt_budmin is less than zero, it causes errors
in the later stages. Added a check to return an error beforehand in dbAllocCtl itself.

---
 fs/jfs/jfs_dmap.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_dmap.c +5 -0
index 974ecf5e0d95..f65a07252c22 100644
@@ -1808,6 +1808,7 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
 	s64 b, lblkno, n;
 	struct metapage *mp;
 	struct dmap *dp;
+	dmtree_t *tp;
 
 	/* check if the allocation request is confined to a single dmap.
 	 */
@@ -1819,6 +1820,10 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
 		if (mp == NULL)
 			return -EIO;
 		dp = (struct dmap *) mp->data;
+		tp = (dmtree_t *) &dp->tree;
+
+		if (tp->dmt_budmin < 0)
+			return -EIO;
 
 		/* try to allocate the blocks.
 		 */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 24 lines · Ghanshyam Agrawal

When dmt_budmin is less than zero, it causes errors
in the later stages. Added a check to return an error beforehand in dbAllocCtl itself.

---
  fs/jfs/jfs_dmap.c | 5 +++++
  1 file changed, 5 insertions(+)
fs/jfs/jfs_dmap.c +1 -0
index 974ecf5e0d95..f65a07252c22 100644
@@ -1808,6 +1808,7 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
  	s64 b, lblkno, n;
  	struct metapage *mp;
  	struct dmap *dp;
+	dmtree_t *tp;
 
  	/* check if the allocation request is confined to a single dmap.
  	 */

fs/jfs/jfs_dmap.c dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results) · line 1826

Quoted 7 lines
fs/jfs/jfs_dmap.c +4 -0
@@ -1819,6 +1820,10 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
  		if (mp == NULL)
  			return -EIO;
  		dp = (struct dmap *) mp->data;
+		tp = (dmtree_t *) &dp->tree;
+
+		if (tp->dmt_budmin < 0)
+			return -EIO;

I'm simplifying this to:

		if (dp->tree.budmin < 0)
			return -EIO;

fs/jfs/jfs_dmap.c dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results) · line 1829

Quoted 3 lines
fs/jfs/jfs_dmap.c +0 -0
  		/* try to allocate the blocks.
  		 */

Other than that. It looks good. I'll apply it.

Shaggy