linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/hfsplus: expand s_vhdr_buf size to avoid slab oob
       [not found] <000000000000820e380606161640@google.com>
@ 2023-09-26 10:24 ` Edward AD
  2024-07-04 14:05   ` Dmitry Vyukov
  2025-05-04  9:52 ` [syzbot] [hfs?] [mm?] KASAN: slab-out-of-bounds Read in generic_perform_write syzbot
  1 sibling, 1 reply; 3+ messages in thread
From: Edward AD @ 2023-09-26 10:24 UTC (permalink / raw)
  To: syzbot+4a2376bc62e59406c414
  Cc: akpm, hughd, linux-fsdevel, linux-kernel, linux-mm, syzkaller-bugs

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@syzkaller.appspotmail.com
Signed-off-by: Edward AD <twuufnxlz@gmail.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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/hfsplus: expand s_vhdr_buf size to avoid slab oob
  2023-09-26 10:24 ` [PATCH] fs/hfsplus: expand s_vhdr_buf size to avoid slab oob Edward AD
@ 2024-07-04 14:05   ` Dmitry Vyukov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Vyukov @ 2024-07-04 14:05 UTC (permalink / raw)
  To: twuufnxlz
  Cc: akpm, hughd, linux-fsdevel, linux-kernel, linux-mm,
	syzbot+4a2376bc62e59406c414, syzkaller-bugs

Hi Edward,

Was this patch lost? I don't see it merged anywhere.
This bug is still present in most kernels out there.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] [hfs?] [mm?] KASAN: slab-out-of-bounds Read in generic_perform_write
       [not found] <000000000000820e380606161640@google.com>
  2023-09-26 10:24 ` [PATCH] fs/hfsplus: expand s_vhdr_buf size to avoid slab oob Edward AD
@ 2025-05-04  9:52 ` syzbot
  1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2025-05-04  9:52 UTC (permalink / raw)
  To: akpm, almaz.alexandrovich, dvyukov, eadavis, hughd,
	linux-fsdevel, linux-kernel, linux-mm, ntfs3, syzkaller-bugs,
	tintinm2017, twuufnxlz

syzbot suspects this issue was fixed by commit:

commit b432163ebd15a0fb74051949cb61456d6c55ccbd
Author: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Date:   Thu Jan 30 14:03:41 2025 +0000

    fs/ntfs3: Update inode->i_mapping->a_ops on compression state

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=115c5b68580000
start commit:   fc033cf25e61 Linux 6.13-rc5
git tree:       upstream
kernel config:  https://syzkaller.appspot.com/x/.config?x=ba7cde9482d6bb6
dashboard link: https://syzkaller.appspot.com/bug?extid=4a2376bc62e59406c414
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1654aac4580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13ff26df980000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: fs/ntfs3: Update inode->i_mapping->a_ops on compression state

For information about bisection process see: https://goo.gl/tpsmEJ#bisection


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-04  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <000000000000820e380606161640@google.com>
2023-09-26 10:24 ` [PATCH] fs/hfsplus: expand s_vhdr_buf size to avoid slab oob Edward AD
2024-07-04 14:05   ` Dmitry Vyukov
2025-05-04  9:52 ` [syzbot] [hfs?] [mm?] KASAN: slab-out-of-bounds Read in generic_perform_write syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox