openbsd-ext4/writeup/3.md

1023 B

Mount source code

Let's look at OpenBSD's mounting, as present in ext2fs_vfsops.c.

The first two function declarations prove quite useful:

int ext2fs_sbupdate(struct ufsmount *, int);
static int	e2fs_sbcheck(struct ext2fs *, int);

The first thing we are concerned with, of course, is the super block. With that being said, let's keep reading.

Below that, we have a struct called ext2fs_vfsops which just contains values that are defined as certain constants (e.g. .vfs_mount = ext2fs_mount), but we don't care about that. Then we have the inode pool, the ext2gennumber, and below that, we have the initializer of the inode pool, which probably needs to be tweaked for 64-bit as well. No wonder nobody has done it 😅

At this point, we should see where in the mounting process ext4 fails. Create an ext4 filesystem using qemu and mount it; make sure that the virtual machine manager marks it as a readonly filesystem before mounting it to ensure that it doesn't get corrupted (at least, not yet).