lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230926102454.992535-2-twuufnxlz@gmail.com>
Date:   Tue, 26 Sep 2023 18:24:55 +0800
From:   Edward AD <twuufnxlz@...il.com>
To:     syzbot+4a2376bc62e59406c414@...kaller.appspotmail.com
Cc:     akpm@...ux-foundation.org, hughd@...gle.com,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, syzkaller-bugs@...glegroups.com
Subject: [PATCH] fs/hfsplus: expand s_vhdr_buf size to avoid slab oob

The memory allocated to s_vhdr_buf in the function hfsplus-read_wrapper is 
too small, resulting in a slab out of bounds issue when copying data with 
copy_page_from_iter_atomic.

When allocating memory to s_vhdr_buf, take the maximum value between 
hfsplus_min_io_size(sb) and PAGE_SIZE to avoid similar issues.

Reported-and-tested-by: syzbot+4a2376bc62e59406c414@...kaller.appspotmail.com
Signed-off-by: Edward AD <twuufnxlz@...il.com>
---
 fs/hfsplus/wrapper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index 0b791adf02e5..56bee8dbe532 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -163,7 +163,7 @@ int hfsplus_read_wrapper(struct super_block *sb)
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	struct hfsplus_wd wd;
 	sector_t part_start, part_size;
-	u32 blocksize;
+	u32 blocksize, bufsize;
 	int error = 0;
 
 	error = -EINVAL;
@@ -175,10 +175,11 @@ int hfsplus_read_wrapper(struct super_block *sb)
 		goto out;
 
 	error = -ENOMEM;
-	sbi->s_vhdr_buf = kmalloc(hfsplus_min_io_size(sb), GFP_KERNEL);
+	bufsize = max_t(u32, hfsplus_min_io_size(sb), PAGE_SIZE);
+	sbi->s_vhdr_buf = kmalloc(bufsize, GFP_KERNEL);
 	if (!sbi->s_vhdr_buf)
 		goto out;
-	sbi->s_backup_vhdr_buf = kmalloc(hfsplus_min_io_size(sb), GFP_KERNEL);
+	sbi->s_backup_vhdr_buf = kmalloc(bufsize, GFP_KERNEL);
 	if (!sbi->s_backup_vhdr_buf)
 		goto out_free_vhdr;
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ