jfs: fix shift-out-of-bounds in dbSplit
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.
Reported-by [email protected]
Signed-off-by Ghanshyam Agrawal <[email protected]>
--- fs/jfs/jfs_dmap.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/jfs/jfs_dmap.c +5 -0
@@ -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
Quoted 24 lines · Ghanshyam Agrawal
When
dmt_budminis less than zero, it causes errors
in the later stages. Added a check to return an error beforehand in dbAllocCtl itself.Reported-by [email protected]Signed-off-by Ghanshyam Agrawal <[email protected]>--- fs/jfs/jfs_dmap.c | 5 +++++ 1 file changed, 5 insertions(+)fs/jfs/jfs_dmap.c +1
-0@@ -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