From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F33093F4DDB; Wed, 20 May 2026 18:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300054; cv=none; b=cURN7fzd23Q4AdjDHTKW0yXKukxPFslWE32iJxsTNZ8FxmpwHuF4vaOlZQnzsI6AYiBiXtidZT774ffvJIov1dabezx2x2+unX/wUtFPbXTcl9nQW8tOlIiknoyP9BzPKQ5VsNRa9uHa1gfcukxN2v6LMqnTMNrWed/q6N7bdZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300054; c=relaxed/simple; bh=DO8NYTTT3WiowPBtraCDPWqv5POwEP8HA/Uo7uq6FyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pa+ZT17ZMiYR6XFnIj1uc1TR0jwCkbe6eDeHLr7mK2WTW821zx1DkcKKnm1u8aFBSz/GPnuuQZcblgef6Iww+2zOo0IrGlpIa61avP/Vnj1sH2JY/Sr7uzvbdxnWlFZb4kTGb5ARD95WuzPf3fPcJLeedlyQatTDmJff0qsEGLs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jWNqaktm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jWNqaktm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 644AA1F000E9; Wed, 20 May 2026 18:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779300052; bh=aUwdfKgghO67uMLG3P0YhLkxJV+UtUyOxQxSW1CWslQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jWNqaktmxbAb9xN9UTQyYcp2Obmv9OGq3XD5sZqFpgtL5wcVAHuT7iXgg2NExEDNA wXnFzBtQL8RuJdTDQ3X08XDBzXTtaS7q26i1S62sYUPQNh7QGwiuDrUCeFptuHIaPq y5vnKWkQIxEsBv/qvGtyn+CRyhfx7Q833Lj7QJDE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hyungjung Joo , Christian Brauner , Sasha Levin Subject: [PATCH 6.12 003/666] fs/omfs: reject s_sys_blocksize smaller than OMFS_DIR_START Date: Wed, 20 May 2026 18:13:34 +0200 Message-ID: <20260520162111.303694033@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: HyungJung Joo [ Upstream commit 0621c385fda1376e967f37ccd534c26c3e511d14 ] 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: a3ab7155ea21 ("omfs: add directory routines") Signed-off-by: Hyungjung Joo Link: https://patch.msgid.link/20260317054827.1822061-1-jhj140711@gmail.com Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/omfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index d6cd811630309..eb5a5fb26a791 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c @@ -512,6 +512,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent) goto out_brelse_bh; } + if (sbi->s_sys_blocksize < OMFS_DIR_START) { + printk(KERN_ERR "omfs: sysblock size (%d) is too small\n", + sbi->s_sys_blocksize); + goto out_brelse_bh; + } + if (sbi->s_blocksize < sbi->s_sys_blocksize || sbi->s_blocksize > OMFS_MAX_BLOCK_SIZE) { printk(KERN_ERR "omfs: block size (%d) is out of range\n", -- 2.53.0