Skip to content

Commit 79f84af

Browse files
Papya-jgregkh
authored andcommitted
fs/omfs: reject s_sys_blocksize smaller than OMFS_DIR_START
[ Upstream commit 0621c38 ] omfs_fill_super() rejects oversized s_sys_blocksize values (> PAGE_SIZE), but it does not reject values smaller than OMFS_DIR_START (0x1b8 = 440). Later, omfs_make_empty() uses sbi->s_sys_blocksize - OMFS_DIR_START as the length argument to memset(). Since s_sys_blocksize is u32, a crafted filesystem image with s_sys_blocksize < OMFS_DIR_START causes an unsigned underflow there, wrapping to a value near 2^32. That drives a ~4 GiB memset() from bh->b_data + OMFS_DIR_START and overwrites kernel memory far beyond the backing block buffer. Add the corresponding lower-bound check alongside the existing upper-bound check in omfs_fill_super(), so that malformed images are rejected during superblock validation before any filesystem data is processed. Fixes: a3ab715 ("omfs: add directory routines") Signed-off-by: Hyungjung Joo <jhj140711@gmail.com> Link: https://patch.msgid.link/20260317054827.1822061-1-jhj140711@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e8cc75e commit 79f84af

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

fs/omfs/inode.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
512512
goto out_brelse_bh;
513513
}
514514

515+
if (sbi->s_sys_blocksize < OMFS_DIR_START) {
516+
printk(KERN_ERR "omfs: sysblock size (%d) is too small\n",
517+
sbi->s_sys_blocksize);
518+
goto out_brelse_bh;
519+
}
520+
515521
if (sbi->s_blocksize < sbi->s_sys_blocksize ||
516522
sbi->s_blocksize > OMFS_MAX_BLOCK_SIZE) {
517523
printk(KERN_ERR "omfs: block size (%d) is out of range\n",

0 commit comments

Comments
 (0)