[syzbot] [ocfs2?] kernel BUG in ocfs2_remove_extent

4 views
Skip to first unread message

syzbot

unread,
Jun 1, 2025, 2:11:34 AMJun 1
to jl...@evilplan.org, jose...@linux.alibaba.com, linux-...@vger.kernel.org, ma...@fasheh.com, ocfs2...@lists.linux.dev, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c89756bcf406 Merge tag 'pm-6.16-rc1' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15fae6d4580000
kernel config: https://syzkaller.appspot.com/x/.config?x=ded97a85afe9a6c8
dashboard link: https://syzkaller.appspot.com/bug?extid=8882b2f5f48a7170a726
compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-c89756bc.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b21d74e73303/vmlinux-c89756bc.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b778ededeb75/bzImage-c89756bc.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+8882b2...@syzkaller.appspotmail.com

------------[ cut here ]------------
kernel BUG at fs/ocfs2/alloc.c:5581!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5320 Comm: syz.0.0 Not tainted 6.15.0-syzkaller-03478-gc89756bcf406 #0 PREEMPT(full)
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_remove_extent+0x1ecf/0x2020 fs/ocfs2/alloc.c:5581
Code: fa ff ff 48 8b 4c 24 08 80 e1 07 fe c1 38 c1 0f 8c 95 fa ff ff 48 8b 7c 24 08 e8 4c e8 8f fe e9 86 fa ff ff e8 22 08 2d fe 90 <0f> 0b f3 0f 1e fa 44 89 6c 24 10 65 8b 1d f3 25 06 0f bf 07 00 00
RSP: 0018:ffffc9000d3ee980 EFLAGS: 00010287
RAX: ffffffff8392ea2e RBX: ffffc9000d3ef178 RCX: 0000000000100000
RDX: ffffc9000ee94000 RSI: 000000000004f2da RDI: 000000000004f2db
RBP: ffffc9000d3eecd0 R08: ffff88803c8c4880 R09: 0000000000000006
R10: 00000000fffffffc R11: 0000000000000002 R12: 1ffff1100abcf048
R13: 0000000000000007 R14: ffff888055e78240 R15: dffffc0000000000
FS: 00007f98ae9896c0(0000) GS:ffff88808d28f000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb0dc3a17e0 CR3: 000000003e12a000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
ocfs2_remove_btree_range+0xdef/0x1540 fs/ocfs2/alloc.c:5778
ocfs2_commit_truncate+0xb64/0x21d0 fs/ocfs2/alloc.c:7373
ocfs2_truncate_file+0xca2/0x1420 fs/ocfs2/file.c:509
ocfs2_setattr+0x1520/0x1b40 fs/ocfs2/file.c:1212
notify_change+0xb33/0xe40 fs/attr.c:552
do_truncate+0x1a4/0x220 fs/open.c:68
handle_truncate fs/namei.c:3508 [inline]
do_open fs/namei.c:3891 [inline]
path_openat+0x306c/0x3830 fs/namei.c:4046
do_filp_open+0x1fa/0x410 fs/namei.c:4073
do_sys_openat2+0x121/0x1c0 fs/open.c:1437
do_sys_open fs/open.c:1452 [inline]
__do_sys_creat fs/open.c:1530 [inline]
__se_sys_creat fs/open.c:1524 [inline]
__x64_sys_creat+0x8f/0xc0 fs/open.c:1524
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f98adb8e969
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f98ae989038 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f98addb6160 RCX: 00007f98adb8e969
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000200000000040
RBP: 00007f98adc10ab1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f98addb6160 R15: 00007ffd2df48568
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_remove_extent+0x1ecf/0x2020 fs/ocfs2/alloc.c:5581
Code: fa ff ff 48 8b 4c 24 08 80 e1 07 fe c1 38 c1 0f 8c 95 fa ff ff 48 8b 7c 24 08 e8 4c e8 8f fe e9 86 fa ff ff e8 22 08 2d fe 90 <0f> 0b f3 0f 1e fa 44 89 6c 24 10 65 8b 1d f3 25 06 0f bf 07 00 00
RSP: 0018:ffffc9000d3ee980 EFLAGS: 00010287
RAX: ffffffff8392ea2e RBX: ffffc9000d3ef178 RCX: 0000000000100000
RDX: ffffc9000ee94000 RSI: 000000000004f2da RDI: 000000000004f2db
RBP: ffffc9000d3eecd0 R08: ffff88803c8c4880 R09: 0000000000000006
R10: 00000000fffffffc R11: 0000000000000002 R12: 1ffff1100abcf048
R13: 0000000000000007 R14: ffff888055e78240 R15: dffffc0000000000
FS: 00007f98ae9896c0(0000) GS:ffff88808d28f000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffcc92d0d90 CR3: 000000003e12a000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
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 syzk...@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 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

syzbot

unread,
Jun 20, 2025, 2:10:31 AMJun 20
to jl...@evilplan.org, jose...@linux.alibaba.com, linux-...@vger.kernel.org, ma...@fasheh.com, ocfs2...@lists.linux.dev, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 2c923c845768 Add linux-next specific files for 20250619
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=153d9d0c580000
kernel config: https://syzkaller.appspot.com/x/.config?x=58afc4b78b52b7e3
dashboard link: https://syzkaller.appspot.com/bug?extid=8882b2f5f48a7170a726
compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11f23d0c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b4ef8488b2c5/disk-2c923c84.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/97fc575793ea/vmlinux-2c923c84.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b8095fa1838d/bzImage-2c923c84.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/3778419fa82a/mount_0.gz
fsck result: OK (log: https://syzkaller.appspot.com/x/fsck.log?x=1441f5d4580000)

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+8882b2...@syzkaller.appspotmail.com

------------[ cut here ]------------
kernel BUG at fs/ocfs2/alloc.c:5581!
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI
CPU: 1 UID: 0 PID: 6023 Comm: syz.1.19 Not tainted 6.16.0-rc2-next-20250619-syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
RIP: 0010:ocfs2_remove_extent+0x1ecf/0x2020 fs/ocfs2/alloc.c:5581
Code: fa ff ff 48 8b 4c 24 08 80 e1 07 fe c1 38 c1 0f 8c 95 fa ff ff 48 8b 7c 24 08 e8 7c 70 8e fe e9 86 fa ff ff e8 d2 49 2a fe 90 <0f> 0b f3 0f 1e fa 44 89 6c 24 10 65 8b 1d 63 61 09 0f bf 07 00 00
RSP: 0000:ffffc9000216e640 EFLAGS: 00010293
RAX: ffffffff83961ebe RBX: ffffc9000216ee38 RCX: ffff888034273c00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000006
RBP: ffffc9000216e990 R08: ffff888034273c00 R09: 0000000000000006
R10: 00000000fffffffc R11: 0000000000000000 R12: 1ffff1100b8fb49a
R13: 0000000000000006 R14: ffff88805c7da4d0 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff888125d28000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fff5456df38 CR3: 0000000075e08000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
ocfs2_remove_btree_range+0xdef/0x1540 fs/ocfs2/alloc.c:5778
ocfs2_commit_truncate+0xb64/0x21d0 fs/ocfs2/alloc.c:7373
ocfs2_truncate_for_delete fs/ocfs2/inode.c:637 [inline]
ocfs2_wipe_inode fs/ocfs2/inode.c:804 [inline]
ocfs2_delete_inode fs/ocfs2/inode.c:1093 [inline]
ocfs2_evict_inode+0x1138/0x40e0 fs/ocfs2/inode.c:1230
evict+0x501/0x9c0 fs/inode.c:810
ocfs2_dentry_iput+0x247/0x370 fs/ocfs2/dcache.c:407
__dentry_kill+0x209/0x660 fs/dcache.c:669
dput+0x19f/0x2b0 fs/dcache.c:911
__fput+0x68e/0xa70 fs/file_table.c:476
task_work_run+0x1d1/0x260 kernel/task_work.c:227
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0x6b5/0x2300 kernel/exit.c:959
do_group_exit+0x21c/0x2d0 kernel/exit.c:1100
get_signal+0x1286/0x1340 kernel/signal.c:3034
arch_do_signal_or_restart+0x9a/0x750 arch/x86/kernel/signal.c:337
exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:330 [inline]
irqentry_exit_to_user_mode+0x81/0x120 kernel/entry/common.c:184
exc_page_fault+0x9f/0xf0 arch/x86/mm/fault.c:1535
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0033:0x7f056b38e886
Code: Unable to access opcode bytes at 0x7f056b38e85c.
RSP: 002b:00007ffea35be310 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000058 RCX: 00007f056b38e929
RDX: 00007ffea35be350 RSI: 0000000000000000 RDI: 00000000000249f0
RBP: 00007f056b410b39 R08: 0000000000000000 R09: 0000000000000058
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f056b5b5fa0 R14: 00007f056b5b5fa0 R15: 0000000000000002
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_remove_extent+0x1ecf/0x2020 fs/ocfs2/alloc.c:5581
Code: fa ff ff 48 8b 4c 24 08 80 e1 07 fe c1 38 c1 0f 8c 95 fa ff ff 48 8b 7c 24 08 e8 7c 70 8e fe e9 86 fa ff ff e8 d2 49 2a fe 90 <0f> 0b f3 0f 1e fa 44 89 6c 24 10 65 8b 1d 63 61 09 0f bf 07 00 00
RSP: 0000:ffffc9000216e640 EFLAGS: 00010293
RAX: ffffffff83961ebe RBX: ffffc9000216ee38 RCX: ffff888034273c00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000006
RBP: ffffc9000216e990 R08: ffff888034273c00 R09: 0000000000000006
R10: 00000000fffffffc R11: 0000000000000000 R12: 1ffff1100b8fb49a
R13: 0000000000000006 R14: ffff88805c7da4d0 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff888125d28000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7a6d9f37b0 CR3: 00000000338ec000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
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.

syzbot

unread,
Aug 28, 2025, 9:50:36 PMAug 28
to jl...@evilplan.org, jose...@linux.alibaba.com, linux-...@vger.kernel.org, ma...@fasheh.com, ocfs2...@lists.linux.dev, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 07d9df80082b Merge tag 'perf-tools-fixes-for-v6.17-2025-08..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17bdfc42580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a7016efe6aaa498c
dashboard link: https://syzkaller.appspot.com/bug?extid=8882b2f5f48a7170a726
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=115a4262580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13087ef0580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-07d9df80.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/64a01edfb5ff/vmlinux-07d9df80.xz
kernel image: https://storage.googleapis.com/syzbot-assets/78c915400ff9/bzImage-07d9df80.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/7dc3c9b29fa5/mount_0.gz
fsck result: OK (log: https://syzkaller.appspot.com/x/fsck.log?x=165a4262580000)

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+8882b2...@syzkaller.appspotmail.com

------------[ cut here ]------------
kernel BUG at fs/ocfs2/alloc.c:5581!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5722 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full)
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_remove_extent+0x1ecf/0x2020 fs/ocfs2/alloc.c:5581
Code: fa ff ff 48 8b 4c 24 08 80 e1 07 fe c1 38 c1 0f 8c 95 fa ff ff 48 8b 7c 24 08 e8 4c 35 8d fe e9 86 fa ff ff e8 f2 48 28 fe 90 <0f> 0b f3 0f 1e fa 44 89 6c 24 10 65 8b 1d d3 9d 09 0f bf 07 00 00
RSP: 0018:ffffc9000d56e640 EFLAGS: 00010293
RAX: ffffffff8397724e RBX: ffffc9000d56ee38 RCX: ffff88803eab8000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000007
RBP: ffffc9000d56e990 R08: ffff88803eab8000 R09: 0000000000000006
R10: 00000000fffffffc R11: 0000000000000000 R12: 1ffff11008b38e9a
R13: 0000000000000007 R14: ffff8880459c74d0 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff88808d20f000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f2cce600218 CR3: 000000004b419000 CR4: 0000000000352ef0
Call Trace:
<TASK>
ocfs2_remove_btree_range+0xdef/0x1540 fs/ocfs2/alloc.c:5778
ocfs2_commit_truncate+0xb64/0x21d0 fs/ocfs2/alloc.c:7373
ocfs2_truncate_for_delete fs/ocfs2/inode.c:699 [inline]
ocfs2_wipe_inode fs/ocfs2/inode.c:866 [inline]
ocfs2_delete_inode fs/ocfs2/inode.c:1155 [inline]
ocfs2_evict_inode+0x1138/0x40e0 fs/ocfs2/inode.c:1292
evict+0x501/0x9c0 fs/inode.c:810
ocfs2_dentry_iput+0x247/0x370 fs/ocfs2/dcache.c:407
__dentry_kill+0x209/0x660 fs/dcache.c:669
dput+0x19f/0x2b0 fs/dcache.c:911
__fput+0x68e/0xa70 fs/file_table.c:476
task_work_run+0x1d4/0x260 kernel/task_work.c:227
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0x6b5/0x2300 kernel/exit.c:961
do_group_exit+0x21c/0x2d0 kernel/exit.c:1102
get_signal+0x1286/0x1340 kernel/signal.c:3034
arch_do_signal_or_restart+0x9a/0x750 arch/x86/kernel/signal.c:337
exit_to_user_mode_loop kernel/entry/common.c:40 [inline]
exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
irqentry_exit_to_user_mode+0x81/0x120 kernel/entry/common.c:73
exc_page_fault+0x9f/0xf0 arch/x86/mm/fault.c:1535
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0033:0x7f018c18ebf1
Code: Unable to access opcode bytes at 0x7f018c18ebc7.
RSP: 002b:00000000fffffeb0 EFLAGS: 00010217
RAX: 0000000000000000 RBX: 00007f018c3b5fa0 RCX: 00007f018c18ebe9
RDX: 0000000000000000 RSI: 00000000fffffeb0 RDI: 0000000002000400
RBP: 00007f018c211e19 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007f018c3b6038 R14: 00007f018c3b5fa0 R15: 00007ffc298dcef8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_remove_extent+0x1ecf/0x2020 fs/ocfs2/alloc.c:5581
Code: fa ff ff 48 8b 4c 24 08 80 e1 07 fe c1 38 c1 0f 8c 95 fa ff ff 48 8b 7c 24 08 e8 4c 35 8d fe e9 86 fa ff ff e8 f2 48 28 fe 90 <0f> 0b f3 0f 1e fa 44 89 6c 24 10 65 8b 1d d3 9d 09 0f bf 07 00 00
RSP: 0018:ffffc9000d56e640 EFLAGS: 00010293
RAX: ffffffff8397724e RBX: ffffc9000d56ee38 RCX: ffff88803eab8000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000007
RBP: ffffc9000d56e990 R08: ffff88803eab8000 R09: 0000000000000006
R10: 00000000fffffffc R11: 0000000000000000 R12: 1ffff11008b38e9a
R13: 0000000000000007 R14: ffff8880459c74d0 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff88808d20f000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f67141f3000 CR3: 00000000333eb000 CR4: 0000000000352ef0

syzbot

unread,
Oct 22, 2025, 11:04:49 AMĀ (yesterday)Ā Oct 22
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 552c50713f273b494ac6c77052032a49bc9255e2
Author: dman...@yandex.ru

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 552c50713f273b494ac6c77052032a49bc9255e2

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 162711cc5b20..ce38505a823c 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6164,7 +6164,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,
struct buffer_head *bh = NULL;
struct ocfs2_dinode *di;
struct ocfs2_truncate_log *tl;
- unsigned int tl_count;
+ unsigned int tl_count, tl_used;

inode = ocfs2_get_system_file_inode(osb,
TRUNCATE_LOG_SYSTEM_INODE,
@@ -6184,9 +6184,10 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,

di = (struct ocfs2_dinode *)bh->b_data;
tl = &di->id2.i_dealloc;
+ tl_used = le16_to_cpu(tl->tl_used);
tl_count = le16_to_cpu(tl->tl_count);
if (unlikely(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) ||
- tl_count == 0)) {
+ tl_count == 0 || tl_used > tl_count)) {
status = -EFSCORRUPTED;
iput(inode);
brelse(bh);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 8c9c4825f984..2785ff245e79 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -302,8 +302,21 @@ static int ocfs2_check_dir_entry(struct inode *dir,
unsigned long offset)
{
const char *error_msg = NULL;
- const int rlen = le16_to_cpu(de->rec_len);
- const unsigned long next_offset = ((char *) de - buf) + rlen;
+ unsigned long next_offset;
+ int rlen;
+
+ if (offset > size - OCFS2_DIR_REC_LEN(1)) {
+ /* Dirent is (maybe partially) beyond the buffer
+ * boundaries so touching 'de' members is unsafe.
+ */
+ mlog(ML_ERROR, "directory entry (#%llu: offset=%lu) "
+ "too close to end or out-of-bounds",
+ (unsigned long long)OCFS2_I(dir)->ip_blkno, offset);
+ return 0;
+ }
+
+ rlen = le16_to_cpu(de->rec_len);
+ next_offset = ((char *) de - buf) + rlen;

if (unlikely(rlen < OCFS2_DIR_REC_LEN(1)))
error_msg = "rec_len is smaller than minimal";
@@ -778,6 +791,14 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
struct ocfs2_extent_block *eb;
struct ocfs2_extent_rec *rec = NULL;

+ if (le16_to_cpu(el->l_count) !=
+ ocfs2_extent_recs_per_dx_root(inode->i_sb)) {
+ ret = ocfs2_error(inode->i_sb,
+ "Inode %lu has invalid extent list length %u\n",
+ inode->i_ino, le16_to_cpu(el->l_count));
+ goto out;
+ }
+
if (el->l_tree_depth) {
ret = ocfs2_find_leaf(INODE_CACHE(inode), el, major_hash,
&eb_bh);
@@ -3423,6 +3444,14 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
offset += le16_to_cpu(de->rec_len);
}

+ if (!last_de) {
+ ret = ocfs2_error(sb, "Directory entry (#%llu: size=%lld) "
+ "is unexpectedly short",
+ (unsigned long long)OCFS2_I(dir)->ip_blkno,
+ i_size_read(dir));
+ goto out;
+ }
+
/*
* We're going to require expansion of the directory - figure
* out how many blocks we'll need so that a place for the
@@ -4104,10 +4133,15 @@ static int ocfs2_expand_inline_dx_root(struct inode *dir,
}

dx_root->dr_flags &= ~OCFS2_DX_FLAG_INLINE;
- memset(&dx_root->dr_list, 0, osb->sb->s_blocksize -
- offsetof(struct ocfs2_dx_root_block, dr_list));
+
+ dx_root->dr_list.l_tree_depth = 0;
dx_root->dr_list.l_count =
cpu_to_le16(ocfs2_extent_recs_per_dx_root(osb->sb));
+ dx_root->dr_list.l_next_free_rec = 0;
+ memset(&dx_root->dr_list.l_recs, 0,
+ osb->sb->s_blocksize -
+ (offsetof(struct ocfs2_dx_root_block, dr_list) +
+ offsetof(struct ocfs2_extent_list, l_recs)));

/* This should never fail considering we start with an empty
* dx_root. */
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index d1aa04a5af1b..56be21c695d6 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -905,13 +905,11 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc)
{
struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc);
- int i;

alloc->id1.bitmap1.i_total = 0;
alloc->id1.bitmap1.i_used = 0;
la->la_bm_off = 0;
- for(i = 0; i < le16_to_cpu(la->la_size); i++)
- la->la_bitmap[i] = 0;
+ memset(la->la_bitmap, 0, le16_to_cpu(la->la_size));
}

#if 0
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 86f2631e6360..ba4952b41602 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -98,7 +98,13 @@ static int __ocfs2_move_extent(handle_t *handle,

rec = &el->l_recs[index];

- BUG_ON(ext_flags != rec->e_flags);
+ if (ext_flags != rec->e_flags) {
+ ret = ocfs2_error(inode->i_sb,
+ "Inode %llu has corrupted extent %d with flags 0x%x at cpos %u\n",
+ (unsigned long long)ino, index, rec->e_flags, cpos);
+ goto out;
+ }
+
/*
* after moving/defraging to new location, the extent is not going
* to be refcounted anymore.
@@ -1031,6 +1037,12 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
if (range.me_threshold > i_size_read(inode))
range.me_threshold = i_size_read(inode);

+ if (range.me_flags & ~(OCFS2_MOVE_EXT_FL_AUTO_DEFRAG |
+ OCFS2_MOVE_EXT_FL_PART_DEFRAG)) {
+ status = -EINVAL;
+ goto out_free;
+ }
+
if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) {
context->auto_defrag = 1;

diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index ae0e44e5f2ad..c501eb3cdcda 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -468,7 +468,8 @@ struct ocfs2_extent_list {
__le16 l_reserved1;
__le64 l_reserved2; /* Pad to
sizeof(ocfs2_extent_rec) */
-/*10*/ struct ocfs2_extent_rec l_recs[]; /* Extent records */
+ /* Extent records */
+/*10*/ struct ocfs2_extent_rec l_recs[] __counted_by_le(l_count);
};

/*
@@ -482,7 +483,8 @@ struct ocfs2_chain_list {
__le16 cl_count; /* Total chains in this list */
__le16 cl_next_free_rec; /* Next unused chain slot */
__le64 cl_reserved1;
-/*10*/ struct ocfs2_chain_rec cl_recs[]; /* Chain records */
+ /* Chain records */
+/*10*/ struct ocfs2_chain_rec cl_recs[] __counted_by_le(cl_count);
};

/*
@@ -494,7 +496,8 @@ struct ocfs2_truncate_log {
/*00*/ __le16 tl_count; /* Total records in this log */
__le16 tl_used; /* Number of records in use */
__le32 tl_reserved1;
-/*08*/ struct ocfs2_truncate_rec tl_recs[]; /* Truncate records */
+ /* Truncate records */
+/*08*/ struct ocfs2_truncate_rec tl_recs[] __counted_by_le(tl_count);
};

/*
@@ -638,7 +641,7 @@ struct ocfs2_local_alloc
__le16 la_size; /* Size of included bitmap, in bytes */
__le16 la_reserved1;
__le64 la_reserved2;
-/*10*/ __u8 la_bitmap[];
+/*10*/ __u8 la_bitmap[] __counted_by_le(la_size);
};

/*
@@ -651,7 +654,7 @@ struct ocfs2_inline_data
* for data, starting at id_data */
__le16 id_reserved0;
__le32 id_reserved1;
- __u8 id_data[]; /* Start of user data */
+ __u8 id_data[] __counted_by_le(id_count); /* Start of user data */
};

/*
@@ -796,9 +799,10 @@ struct ocfs2_dx_entry_list {
* possible in de_entries */
__le16 de_num_used; /* Current number of
* de_entries entries */
- struct ocfs2_dx_entry de_entries[]; /* Indexed dir entries
- * in a packed array of
- * length de_num_used */
+ /* Indexed dir entries in a packed
+ * array of length de_num_used.
+ */
+ struct ocfs2_dx_entry de_entries[] __counted_by_le(de_count);
};

#define OCFS2_DX_FLAG_INLINE 0x01
@@ -934,7 +938,8 @@ struct ocfs2_refcount_list {
__le16 rl_used; /* Current number of used records */
__le32 rl_reserved2;
__le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
-/*10*/ struct ocfs2_refcount_rec rl_recs[]; /* Refcount records */
+ /* Refcount records */
+/*10*/ struct ocfs2_refcount_rec rl_recs[] __counted_by_le(rl_count);
};


@@ -1020,7 +1025,8 @@ struct ocfs2_xattr_header {
buckets. A block uses
xb_check and sets
this field to zero.) */
- struct ocfs2_xattr_entry xh_entries[]; /* xattr entry list. */
+ /* xattr entry list. */
+ struct ocfs2_xattr_entry xh_entries[] __counted_by_le(xh_count);
};

/*
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 6ac4dcd54588..9969a041ab18 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -649,6 +649,16 @@ ocfs2_block_group_alloc_discontig(handle_t *handle,
return status ? ERR_PTR(status) : bg_bh;
}

+static int ocfs2_check_chain_list(struct ocfs2_chain_list *cl,
+ struct super_block *sb)
+{
+ if (le16_to_cpu(cl->cl_count) != ocfs2_chain_recs_per_inode(sb))
+ return -EINVAL;
+ if (le16_to_cpu(cl->cl_next_free_rec) > le16_to_cpu(cl->cl_count))
+ return -EINVAL;
+ return 0;
+}
+
/*
* We expect the block group allocator to already be locked.
*/
@@ -671,6 +681,10 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode));

cl = &fe->id2.i_chain;
+ status = ocfs2_check_chain_list(cl, alloc_inode->i_sb);
+ if (status)
+ goto bail;
+
status = ocfs2_reserve_clusters_with_limit(osb,
le16_to_cpu(cl->cl_cpg),
max_block, flags, &ac);
@@ -1992,6 +2006,9 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
}

cl = (struct ocfs2_chain_list *) &fe->id2.i_chain;
+ status = ocfs2_check_chain_list(cl, ac->ac_inode->i_sb);
+ if (status)
+ goto bail;

victim = ocfs2_find_victim_chain(cl);
ac->ac_chain = victim;
Reply all
Reply to author
Forward
0 new messages