Skip to content

Sector 2-18 zeroed in first partition of msdoshd #379

@Junjus

Description

@Junjus

Description

Following xml results in a problem:

Problem

The first partition of msdos partition table is defined to start at sector 2.
The partition-table starts the first partition at sector 2.

  • If a binary is defined inside the partition, then the binary should start from sector 2 onward.
    However sector 2-18 will be zeroed. The binary is overwritten / never-written in those sectors, while continuing correctly from sector 19 onward.
  • If a ext4 partition is defined, the first superblock with 1024 byte offset (start sector 4), is zeroed. And all following sectors till sector 19.
Test Versions:
  • used debian package: v14.8.1
  • used git main: commit b6d36d3 Fix badly rendered ELBE sphinx docs
XML
<msdoshd>
    ...
    <first_partition_sector>2</first_partition_sector>
    <partition>
         ...
    </partition>
    ...
</msdoshd>

Trace Binary

Partition in partition-table

File attached: msdoshd.zip
losetup -P /dev/loop0 <image>

$ fdisk /dev/loop0

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/loop0: 550 MiB, 576716800 bytes, 1126400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x874709fa

Device       Boot Start     End Sectors  Size Id Type
/dev/loop0p1          2    8193    8192    4M 83 Linux
...
Content of partition

hexdump -Cn 9296 --skip 512 <image>

00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002600  10 bd 2d e9 f7 45 14 46  0f 46 40 6a 1e 46 ff f7  |..-..E.F.F@j.F..|
00002610  9b ff 23 0a 7a 00 8d f8  04 40 8d f8 05 30 08 21  |..#.z....@...0.!|
00002620  23 0c 02 f0 fe 02 24 0e  8d f8 07 40 05 46 8d f8  |#.....$....@.F..|
00002630  06 30 ff f7 6c ff 4f f0  40 0a 04 46 0d f1 04 08  |.0..l.O.@..F....|
00002640  5c b9 00 2e 06 f1 ff 37  10 dc 4f f0 40 08 dd e9  |\......7..O.@...|
00002650

Trace ext4

msdoshd-ext4.zip

losetup -P /dev/loop0 <image>
hexdump -Cn 2048 /dev/loop0p1

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000800

The result should have looked like, if defined outside sectors 2-18:

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  90 88 00 00 ff 21 02 00  4c 1b 00 00 ad 58 00 00  |.....!..L....X..|
00000410  3f 4b 00 00 00 00 00 00  02 00 00 00 02 00 00 00  |?K..............|
00000420  00 80 00 00 00 80 00 00  50 1b 00 00 57 05 76 64  |........P...W.vd|
00000430  65 05 76 64 01 00 ff ff  53 ef 01 00 01 00 00 00  |e.vd....S.......|
00000440  57 05 76 64 00 00 00 00  00 00 00 00 01 00 00 00  |W.vd............|
00000450  00 00 00 00 0b 00 00 00  00 01 00 00 3c 00 00 00  |............<...|
00000460  c2 02 00 00 6b 04 00 00  a3 fd bd 36 fd d5 4a ce  |....k......6..J.|
00000470  ae ce 51 54 bc b8 d8 f8  72 6f 6f 74 66 73 00 00  |..QT....rootfs..|
00000480  00 00 00 00 00 00 00 00  2f 76 61 72 2f 63 61 63  |......../var/cac|
00000490  68 65 2f 65 6c 62 65 2f  66 63 63 37 36 32 38 62  |he/elbe/fcc7628b|
000004a0  2d 65 34 63 66 2d 34 38  63 61 2d 62 32 66 39 2d  |-e4cf-48ca-b2f9-|
000004b0  32 36 64 35 31 33 61 61  61 38 31 35 2f 69 6d 61  |26d513aaa815/ima|
000004c0  67 65 6d 6e 74 00 00 00  00 00 00 00 00 00 44 00  |gemnt.........D.|
000004d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000004e0  08 00 00 00 00 00 00 00  00 00 00 00 4d db 2d 3b  |............M.-;|
000004f0  96 4b 46 3c bb b7 7c 50  d0 f8 d4 c6 01 01 40 00  |.KF<..|P......@.|
00000500  0c 00 00 00 00 00 00 00  57 05 76 64 0a f3 01 00  |........W.vd....|
00000510  04 00 00 00 00 00 00 00  00 00 00 00 00 10 00 00  |................|
00000520  00 00 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000530  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000540  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 01  |................|
00000550  00 00 00 00 00 00 00 00  00 00 00 00 20 00 20 00  |............ . .|
00000560  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000570  00 00 00 00 04 01 00 00  fd 27 07 00 00 00 00 00  |.........'......|
00000580  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000640  00 00 00 00 00 00 00 00  65 19 00 00 00 00 00 00  |........e.......|
00000650  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000007f0  00 00 00 00 00 00 00 00  00 00 00 00 b8 a9 2d 52  |..............-R|
00000800

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions