Skip to content

Commit b9d02c2

Browse files
committed
Merge tag 'jfs-6.5' of github.com:kleikamp/linux-shaggy
Pull jfs updates from David Kleikamp: "Minor bug fixes and cleanups" * tag 'jfs-6.5' of github.com:kleikamp/linux-shaggy: FS: JFS: Check for read-only mounted filesystem in txBegin FS: JFS: Fix null-ptr-deref Read in txBegin fs: jfs: Fix UBSAN: array-index-out-of-bounds in dbAllocDmapLev fs: jfs: (trivial) Fix typo in dbInitTree function jfs: jfs_dmap: Validate db_l2nbperpage while mounting
2 parents be3c213 + 95e2b35 commit b9d02c2

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

fs/jfs/jfs_dmap.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ int dbMount(struct inode *ipbmap)
178178
dbmp_le = (struct dbmap_disk *) mp->data;
179179
bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize);
180180
bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
181+
181182
bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
183+
if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE) {
184+
err = -EINVAL;
185+
goto err_release_metapage;
186+
}
187+
182188
bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag);
183189
if (!bmp->db_numag) {
184190
err = -EINVAL;
@@ -1953,6 +1959,9 @@ dbAllocDmapLev(struct bmap * bmp,
19531959
if (dbFindLeaf((dmtree_t *) & dp->tree, l2nb, &leafidx))
19541960
return -ENOSPC;
19551961

1962+
if (leafidx < 0)
1963+
return -EIO;
1964+
19561965
/* determine the block number within the file system corresponding
19571966
* to the leaf at which free space was found.
19581967
*/
@@ -3851,7 +3860,7 @@ static int dbInitTree(struct dmaptree * dtp)
38513860
l2max = le32_to_cpu(dtp->l2nleafs) + dtp->budmin;
38523861

38533862
/*
3854-
* configure the leaf levevl into binary buddy system
3863+
* configure the leaf level into binary buddy system
38553864
*
38563865
* Try to combine buddies starting with a buddy size of 1
38573866
* (i.e. two leaves). At a buddy size of 1 two buddy leaves

fs/jfs/jfs_filsys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@
122122
#define NUM_INODE_PER_IAG INOSPERIAG
123123

124124
#define MINBLOCKSIZE 512
125+
#define L2MINBLOCKSIZE 9
125126
#define MAXBLOCKSIZE 4096
127+
#define L2MAXBLOCKSIZE 12
126128
#define MAXFILESIZE ((s64)1 << 52)
127129

128130
#define JFS_LINK_MAX 0xffffffff

fs/jfs/jfs_txnmgr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ tid_t txBegin(struct super_block *sb, int flag)
354354
jfs_info("txBegin: flag = 0x%x", flag);
355355
log = JFS_SBI(sb)->log;
356356

357+
if (!log) {
358+
jfs_error(sb, "read-only filesystem\n");
359+
return 0;
360+
}
361+
357362
TXN_LOCK();
358363

359364
INCREMENT(TxStat.txBegin);

fs/jfs/namei.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,11 @@ static int jfs_link(struct dentry *old_dentry,
799799
if (rc)
800800
goto out;
801801

802+
if (isReadOnly(ip)) {
803+
jfs_error(ip->i_sb, "read-only filesystem\n");
804+
return -EROFS;
805+
}
806+
802807
tid = txBegin(ip->i_sb, 0);
803808

804809
mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT);

0 commit comments

Comments
 (0)