mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-28 06:44:36 -05:00
Merge tag 'jfs-6.13' of github.com:kleikamp/linux-shaggy
Pull jfs updates from Dave Kleikamp: "A few more patches to add sanity checks in jfs" * tag 'jfs-6.13' of github.com:kleikamp/linux-shaggy: jfs: add a check to prevent array-index-out-of-bounds in dbAdjTree jfs: xattr: check invalid xattr size more strictly jfs: fix array-index-out-of-bounds in jfs_readdir jfs: fix shift-out-of-bounds in dbSplit jfs: array-index-out-of-bounds fix in dtReadFirst
This commit is contained in:
@@ -1820,6 +1820,9 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
|
||||
return -EIO;
|
||||
dp = (struct dmap *) mp->data;
|
||||
|
||||
if (dp->tree.budmin < 0)
|
||||
return -EIO;
|
||||
|
||||
/* try to allocate the blocks.
|
||||
*/
|
||||
rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results);
|
||||
@@ -2888,6 +2891,9 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
|
||||
/* bubble the new value up the tree as required.
|
||||
*/
|
||||
for (k = 0; k < le32_to_cpu(tp->dmt_height); k++) {
|
||||
if (lp == 0)
|
||||
break;
|
||||
|
||||
/* get the index of the first leaf of the 4 leaf
|
||||
* group containing the specified leaf (leafno).
|
||||
*/
|
||||
|
||||
@@ -2891,6 +2891,14 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
|
||||
stbl = DT_GETSTBL(p);
|
||||
|
||||
for (i = index; i < p->header.nextindex; i++) {
|
||||
if (stbl[i] < 0 || stbl[i] > 127) {
|
||||
jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
|
||||
i, stbl[i], (long)ip->i_ino, (long long)bn);
|
||||
free_page(dirent_buf);
|
||||
DT_PUTPAGE(mp);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
d = (struct ldtentry *) & p->slot[stbl[i]];
|
||||
|
||||
if (((long) jfs_dirent + d->namlen + 1) >
|
||||
@@ -3086,6 +3094,13 @@ static int dtReadFirst(struct inode *ip, struct btstack * btstack)
|
||||
|
||||
/* get the leftmost entry */
|
||||
stbl = DT_GETSTBL(p);
|
||||
|
||||
if (stbl[0] < 0 || stbl[0] > 127) {
|
||||
DT_PUTPAGE(mp);
|
||||
jfs_error(ip->i_sb, "stbl[0] out of bound\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
xd = (pxd_t *) & p->slot[stbl[0]];
|
||||
|
||||
/* get the child page block address */
|
||||
|
||||
@@ -559,7 +559,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
|
||||
|
||||
size_check:
|
||||
if (EALIST_SIZE(ea_buf->xattr) != ea_size) {
|
||||
int size = min_t(int, EALIST_SIZE(ea_buf->xattr), ea_size);
|
||||
int size = clamp_t(int, ea_size, 0, EALIST_SIZE(ea_buf->xattr));
|
||||
|
||||
printk(KERN_ERR "ea_get: invalid extended attribute\n");
|
||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1,
|
||||
|
||||
Reference in New Issue
Block a user