* [syzbot] [ocfs2?] general protection fault in ocfs2_prepare_dir_for_insert
@ 2024-08-20 7:58 syzbot
2024-08-20 11:19 ` Edward Adam Davis
2024-08-20 12:08 ` [PATCH] ocfs2: Add i_size check for dir Edward Adam Davis
0 siblings, 2 replies; 11+ messages in thread
From: syzbot @ 2024-08-20 7:58 UTC (permalink / raw)
To: jlbec, joseph.qi, linux-kernel, mark, ocfs2-devel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: b0da640826ba Merge tag 'printk-for-6.11-rc5' of git://git...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10d2076b980000
kernel config: https://syzkaller.appspot.com/x/.config?x=df2f0ed7e30a639d
dashboard link: https://syzkaller.appspot.com/bug?extid=5a64828fcc4c2ad9b04f
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1680ffcb980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=153aec05980000
Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7bc7510fe41f/non_bootable_disk-b0da6408.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f630005f615b/vmlinux-b0da6408.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4e3e4edbec91/bzImage-b0da6408.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/1a3cbd9c01e6/mount_0.gz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+5a64828fcc4c2ad9b04f@syzkaller.appspotmail.com
loop0: detected capacity change from 0 to 32768
JBD2: Ignoring recovery information on journal
ocfs2: Mounting device (7,0) on (node local, slot 0) with ordered data mode.
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 0 UID: 0 PID: 5096 Comm: syz-executor792 Not tainted 6.11.0-rc4-syzkaller-00002-gb0da640826ba #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:ocfs2_find_dir_space_id fs/ocfs2/dir.c:3406 [inline]
RIP: 0010:ocfs2_prepare_dir_for_insert+0x3309/0x5c70 fs/ocfs2/dir.c:4280
Code: 00 00 e8 2a 25 13 fe e9 ba 06 00 00 e8 20 25 13 fe e9 4f 01 00 00 e8 16 25 13 fe 49 8d 7f 08 49 8d 5f 09 48 89 f8 48 c1 e8 03 <42> 0f b6 04 20 84 c0 0f 85 bd 23 00 00 48 89 d8 48 c1 e8 03 42 0f
RSP: 0018:ffffc9000af9f020 EFLAGS: 00010202
RAX: 0000000000000001 RBX: 0000000000000009 RCX: ffff88801e27a440
RDX: 0000000000000000 RSI: 0000000000000400 RDI: 0000000000000008
RBP: ffffc9000af9f830 R08: ffffffff8380395b R09: ffffffff838090a7
R10: 0000000000000002 R11: ffff88801e27a440 R12: dffffc0000000000
R13: ffff88803c660878 R14: f700000000000088 R15: 0000000000000000
FS: 000055555a677380(0000) GS:ffff888020800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000560bce569178 CR3: 000000001de5a000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
ocfs2_mknod+0xcaf/0x2b40 fs/ocfs2/namei.c:292
vfs_mknod+0x36d/0x3b0 fs/namei.c:4088
do_mknodat+0x3ec/0x5b0
__do_sys_mknodat fs/namei.c:4166 [inline]
__se_sys_mknodat fs/namei.c:4163 [inline]
__x64_sys_mknodat+0xa7/0xc0 fs/namei.c:4163
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f2dafda3a99
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe336a6658 EFLAGS: 00000246 ORIG_RAX: 0000000000000103
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f2dafda3a99
RDX: 00000000000021c0 RSI: 0000000020000040 RDI: 00000000ffffff9c
RBP: 00007f2dafe1b5f0 R08: 0000000000004480 R09: 000055555a6784c0
R10: 0000000000000103 R11: 0000000000000246 R12: 00007ffe336a6680
R13: 00007ffe336a68a8 R14: 431bde82d7b634db R15: 00007f2dafdec03b
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_find_dir_space_id fs/ocfs2/dir.c:3406 [inline]
RIP: 0010:ocfs2_prepare_dir_for_insert+0x3309/0x5c70 fs/ocfs2/dir.c:4280
Code: 00 00 e8 2a 25 13 fe e9 ba 06 00 00 e8 20 25 13 fe e9 4f 01 00 00 e8 16 25 13 fe 49 8d 7f 08 49 8d 5f 09 48 89 f8 48 c1 e8 03 <42> 0f b6 04 20 84 c0 0f 85 bd 23 00 00 48 89 d8 48 c1 e8 03 42 0f
RSP: 0018:ffffc9000af9f020 EFLAGS: 00010202
RAX: 0000000000000001 RBX: 0000000000000009 RCX: ffff88801e27a440
RDX: 0000000000000000 RSI: 0000000000000400 RDI: 0000000000000008
RBP: ffffc9000af9f830 R08: ffffffff8380395b R09: ffffffff838090a7
R10: 0000000000000002 R11: ffff88801e27a440 R12: dffffc0000000000
R13: ffff88803c660878 R14: f700000000000088 R15: 0000000000000000
FS: 000055555a677380(0000) GS:ffff888020800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000560bce569178 CR3: 000000001de5a000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 00 00 add %al,(%rax)
2: e8 2a 25 13 fe call 0xfe132531
7: e9 ba 06 00 00 jmp 0x6c6
c: e8 20 25 13 fe call 0xfe132531
11: e9 4f 01 00 00 jmp 0x165
16: e8 16 25 13 fe call 0xfe132531
1b: 49 8d 7f 08 lea 0x8(%r15),%rdi
1f: 49 8d 5f 09 lea 0x9(%r15),%rbx
23: 48 89 f8 mov %rdi,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 0f b6 04 20 movzbl (%rax,%r12,1),%eax <-- trapping instruction
2f: 84 c0 test %al,%al
31: 0f 85 bd 23 00 00 jne 0x23f4
37: 48 89 d8 mov %rbx,%rax
3a: 48 c1 e8 03 shr $0x3,%rax
3e: 42 rex.X
3f: 0f .byte 0xf
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [syzbot] [ocfs2?] general protection fault in ocfs2_prepare_dir_for_insert
2024-08-20 7:58 [syzbot] [ocfs2?] general protection fault in ocfs2_prepare_dir_for_insert syzbot
@ 2024-08-20 11:19 ` Edward Adam Davis
2024-08-20 11:42 ` syzbot
2024-08-20 12:08 ` [PATCH] ocfs2: Add i_size check for dir Edward Adam Davis
1 sibling, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2024-08-20 11:19 UTC (permalink / raw)
To: syzbot+5a64828fcc4c2ad9b04f
Cc: jlbec, joseph.qi, linux-kernel, mark, ocfs2-devel, syzkaller-bugs
i_size_read(dir) too big, make limit overflow, cause last_de uninit.
#syz test: upstream b0da640826ba
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index d620d4c53c6f..c308dba6d213 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -3343,6 +3343,8 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
unsigned long offset = 0;
unsigned int rec_len, new_rec_len, free_space;
+ if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
+ return -EINVAL;
/*
* This calculates how many free bytes we'd have in block zero, should
* this function force expansion to an extent tree.
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] ocfs2: Add i_size check for dir
2024-08-20 7:58 [syzbot] [ocfs2?] general protection fault in ocfs2_prepare_dir_for_insert syzbot
2024-08-20 11:19 ` Edward Adam Davis
@ 2024-08-20 12:08 ` Edward Adam Davis
2024-08-20 12:44 ` Joseph Qi
2024-08-20 14:59 ` Matthew Wilcox
1 sibling, 2 replies; 11+ messages in thread
From: Edward Adam Davis @ 2024-08-20 12:08 UTC (permalink / raw)
To: syzbot+5a64828fcc4c2ad9b04f
Cc: jlbec, joseph.qi, linux-kernel, mark, ocfs2-devel, syzkaller-bugs
When the i_size of dir is too large, it will cause limit to overflow and
be less than de_buf, ultimately resulting in last_de not being initialized
and causing uaf issue.
Reported-and-tested-by: syzbot+5a64828fcc4c2ad9b04f@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/ocfs2/dir.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index d620d4c53c6f..c308dba6d213 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -3343,6 +3343,8 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
unsigned long offset = 0;
unsigned int rec_len, new_rec_len, free_space;
+ if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
+ return -EINVAL;
/*
* This calculates how many free bytes we'd have in block zero, should
* this function force expansion to an extent tree.
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-20 12:08 ` [PATCH] ocfs2: Add i_size check for dir Edward Adam Davis
@ 2024-08-20 12:44 ` Joseph Qi
2024-08-20 13:55 ` Edward Adam Davis
2024-08-20 14:59 ` Matthew Wilcox
1 sibling, 1 reply; 11+ messages in thread
From: Joseph Qi @ 2024-08-20 12:44 UTC (permalink / raw)
To: Edward Adam Davis, syzbot+5a64828fcc4c2ad9b04f
Cc: jlbec, linux-kernel, mark, ocfs2-devel, syzkaller-bugs
On 8/20/24 8:08 PM, Edward Adam Davis wrote:
> When the i_size of dir is too large, it will cause limit to overflow and
> be less than de_buf, ultimately resulting in last_de not being initialized
> and causing uaf issue.
>
> Reported-and-tested-by: syzbot+5a64828fcc4c2ad9b04f@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> fs/ocfs2/dir.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index d620d4c53c6f..c308dba6d213 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -3343,6 +3343,8 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
> unsigned long offset = 0;
> unsigned int rec_len, new_rec_len, free_space;
>
> + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
> + return -EINVAL;
Why OCFS2_MAX_BLOCKSIZE?
It seems that this is caused by a corrupted dir inode, since this is an
inline case, we may try best to make sure it won't exceeds block size?
i.e. dir->i_sb->s_blocksize.
Thanks,
Joseph
> /*
> * This calculates how many free bytes we'd have in block zero, should
> * this function force expansion to an extent tree.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-20 12:44 ` Joseph Qi
@ 2024-08-20 13:55 ` Edward Adam Davis
2024-08-21 10:41 ` Joseph Qi
0 siblings, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2024-08-20 13:55 UTC (permalink / raw)
To: joseph.qi
Cc: eadavis, jlbec, linux-kernel, mark, ocfs2-devel,
syzbot+5a64828fcc4c2ad9b04f, syzkaller-bugs
On Tue, 20 Aug 2024 20:44:37 +0800, Joseph Qi wrote:
> > When the i_size of dir is too large, it will cause limit to overflow and
> > be less than de_buf, ultimately resulting in last_de not being initialized
> > and causing uaf issue.
> >
> > Reported-and-tested-by: syzbot+5a64828fcc4c2ad9b04f@syzkaller.appspotmail.com
> > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > ---
> > fs/ocfs2/dir.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> > index d620d4c53c6f..c308dba6d213 100644
> > --- a/fs/ocfs2/dir.c
> > +++ b/fs/ocfs2/dir.c
> > @@ -3343,6 +3343,8 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
> > unsigned long offset = 0;
> > unsigned int rec_len, new_rec_len, free_space;
> >
> > + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
> > + return -EINVAL;
>
> Why OCFS2_MAX_BLOCKSIZE?
I think it is largest block size in ocfs2, therefore, if it is larger
than it, it must be incorrect, even though the value of i_size in dir
in the current issue is much larger than it (i_size_read(dir) is 0x900000000000100).
> It seems that this is caused by a corrupted dir inode, since this is an
> inline case, we may try best to make sure it won't exceeds block size?
> i.e. dir->i_sb->s_blocksize.
You mean dir->i_sb->s_blocksize bigger than OCFS2_MAX_BLOCKSIZE?
BR,
Edward
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-20 13:55 ` Edward Adam Davis
@ 2024-08-21 10:41 ` Joseph Qi
2024-08-21 11:15 ` Edward Adam Davis
0 siblings, 1 reply; 11+ messages in thread
From: Joseph Qi @ 2024-08-21 10:41 UTC (permalink / raw)
To: Edward Adam Davis
Cc: jlbec, linux-kernel, mark, ocfs2-devel,
syzbot+5a64828fcc4c2ad9b04f, syzkaller-bugs
On 8/20/24 9:55 PM, Edward Adam Davis wrote:
> On Tue, 20 Aug 2024 20:44:37 +0800, Joseph Qi wrote:
>>> When the i_size of dir is too large, it will cause limit to overflow and
>>> be less than de_buf, ultimately resulting in last_de not being initialized
>>> and causing uaf issue.
>>>
>>> Reported-and-tested-by: syzbot+5a64828fcc4c2ad9b04f@syzkaller.appspotmail.com
>>> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
>>> ---
>>> fs/ocfs2/dir.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>>> index d620d4c53c6f..c308dba6d213 100644
>>> --- a/fs/ocfs2/dir.c
>>> +++ b/fs/ocfs2/dir.c
>>> @@ -3343,6 +3343,8 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
>>> unsigned long offset = 0;
>>> unsigned int rec_len, new_rec_len, free_space;
>>>
>>> + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
>>> + return -EINVAL;
>>
>> Why OCFS2_MAX_BLOCKSIZE?
> I think it is largest block size in ocfs2, therefore, if it is larger
> than it, it must be incorrect, even though the value of i_size in dir
> in the current issue is much larger than it (i_size_read(dir) is 0x900000000000100).
>> It seems that this is caused by a corrupted dir inode, since this is an
>> inline case, we may try best to make sure it won't exceeds block size?
>> i.e. dir->i_sb->s_blocksize.
> You mean dir->i_sb->s_blocksize bigger than OCFS2_MAX_BLOCKSIZE?
>
No, I mean check s_blocksize seems more reasonable rather than
OCFS2_MAX_BLOCKSIZE.
Thanks,
Joseph
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-21 10:41 ` Joseph Qi
@ 2024-08-21 11:15 ` Edward Adam Davis
0 siblings, 0 replies; 11+ messages in thread
From: Edward Adam Davis @ 2024-08-21 11:15 UTC (permalink / raw)
To: joseph.qi
Cc: eadavis, jlbec, linux-kernel, mark, ocfs2-devel,
syzbot+5a64828fcc4c2ad9b04f, syzkaller-bugs
On Wed, 21 Aug 2024 18:41:06 +0800, Joseph Qi wrote:
>>>> When the i_size of dir is too large, it will cause limit to overflow and
>>>> be less than de_buf, ultimately resulting in last_de not being initialized
>>>> and causing uaf issue.
>>>>
>>>> Reported-and-tested-by: syzbot+5a64828fcc4c2ad9b04f@syzkaller.appspotmail.com
>>>> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
>>>> ---
>>>> fs/ocfs2/dir.c | 2 ++
>>>> 1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>>>> index d620d4c53c6f..c308dba6d213 100644
>>>> --- a/fs/ocfs2/dir.c
>>>> +++ b/fs/ocfs2/dir.c
>>>> @@ -3343,6 +3343,8 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
>>>> unsigned long offset = 0;
>>>> unsigned int rec_len, new_rec_len, free_space;
>>>>
>>>> + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
>>>> + return -EINVAL;
>>>
>>> Why OCFS2_MAX_BLOCKSIZE?
>> I think it is largest block size in ocfs2, therefore, if it is larger
>> than it, it must be incorrect, even though the value of i_size in dir
>> in the current issue is much larger than it (i_size_read(dir) is 0x900000000000100).
>>> It seems that this is caused by a corrupted dir inode, since this is an
>>> inline case, we may try best to make sure it won't exceeds block size?
>>> i.e. dir->i_sb->s_blocksize.
>> You mean dir->i_sb->s_blocksize bigger than OCFS2_MAX_BLOCKSIZE?
>>
>No, I mean check s_blocksize seems more reasonable rather than
>OCFS2_MAX_BLOCKSIZE.
Perhaps we have different perspectives on the issue.
My approach is to set a bottom line for the dir's i_size, and if it
exceeds the bottom line, the dir will definitely be corrupted.
And I think OCFS2_MAX_BLOCKSIZE is the reasonable bottom line.
BR,
Edward
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-20 12:08 ` [PATCH] ocfs2: Add i_size check for dir Edward Adam Davis
2024-08-20 12:44 ` Joseph Qi
@ 2024-08-20 14:59 ` Matthew Wilcox
2024-08-21 6:16 ` heming.zhao
2024-08-21 9:08 ` Edward Adam Davis
1 sibling, 2 replies; 11+ messages in thread
From: Matthew Wilcox @ 2024-08-20 14:59 UTC (permalink / raw)
To: Edward Adam Davis
Cc: syzbot+5a64828fcc4c2ad9b04f, jlbec, joseph.qi, linux-kernel, mark,
ocfs2-devel, syzkaller-bugs
On Tue, Aug 20, 2024 at 08:08:38PM +0800, Edward Adam Davis wrote:
> When the i_size of dir is too large, it will cause limit to overflow and
> be less than de_buf, ultimately resulting in last_de not being initialized
> and causing uaf issue.
>
> + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
> + return -EINVAL;
Surely directories can be more than one block in size?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-20 14:59 ` Matthew Wilcox
@ 2024-08-21 6:16 ` heming.zhao
2024-08-21 9:08 ` Edward Adam Davis
1 sibling, 0 replies; 11+ messages in thread
From: heming.zhao @ 2024-08-21 6:16 UTC (permalink / raw)
To: Matthew Wilcox, joseph.qi, Edward Adam Davis
Cc: syzbot+5a64828fcc4c2ad9b04f, jlbec, linux-kernel, mark,
ocfs2-devel, syzkaller-bugs
On 8/20/24 22:59, Matthew Wilcox wrote:
> On Tue, Aug 20, 2024 at 08:08:38PM +0800, Edward Adam Davis wrote:
>> When the i_size of dir is too large, it will cause limit to overflow and
>> be less than de_buf, ultimately resulting in last_de not being initialized
>> and causing uaf issue.
>>
>> + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
>> + return -EINVAL;
>
> Surely directories can be more than one block in size?
>
The key point above is that the patch uses a hard code value, but in the real world,
the blocksize can be smaller than OCFS2_MAX_BLOCKSIZE.
-Heming
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ocfs2: Add i_size check for dir
2024-08-20 14:59 ` Matthew Wilcox
2024-08-21 6:16 ` heming.zhao
@ 2024-08-21 9:08 ` Edward Adam Davis
1 sibling, 0 replies; 11+ messages in thread
From: Edward Adam Davis @ 2024-08-21 9:08 UTC (permalink / raw)
To: willy
Cc: eadavis, jlbec, joseph.qi, linux-kernel, mark, ocfs2-devel,
syzbot+5a64828fcc4c2ad9b04f, syzkaller-bugs
On Tue, 20 Aug 2024 15:59:56 +0100, Matthew Wilcox wrote:
> > When the i_size of dir is too large, it will cause limit to overflow and
> > be less than de_buf, ultimately resulting in last_de not being initialized
> > and causing uaf issue.
> >
> > + if (i_size_read(dir) > OCFS2_MAX_BLOCKSIZE)
> > + return -EINVAL;
>
> Surely directories can be more than one block in size?
In this issue, Yes.
--
Edward
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-08-21 11:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 7:58 [syzbot] [ocfs2?] general protection fault in ocfs2_prepare_dir_for_insert syzbot
2024-08-20 11:19 ` Edward Adam Davis
2024-08-20 11:42 ` syzbot
2024-08-20 12:08 ` [PATCH] ocfs2: Add i_size check for dir Edward Adam Davis
2024-08-20 12:44 ` Joseph Qi
2024-08-20 13:55 ` Edward Adam Davis
2024-08-21 10:41 ` Joseph Qi
2024-08-21 11:15 ` Edward Adam Davis
2024-08-20 14:59 ` Matthew Wilcox
2024-08-21 6:16 ` heming.zhao
2024-08-21 9:08 ` Edward Adam Davis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox