landlock-lsm / linux

Linux kernel - See Landlock issues
https://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git/
Other
33 stars 9 forks source link

Test with more filesystems #21

Open l0kod opened 5 months ago

l0kod commented 5 months ago

We currently perform testing on a set of synthetic filesystems (e.g. tmpfs, proc, sysfs) thanks to the layout3_fs test variants.

It would be useful to add new tests for more filesystems (e.g. ext4, btrfs, f2fs, erofs, vfat, ntfs, fuse, nfs) to make sure they are consistent with Landlock sandboxing. One of the challenges is to cleanly integrate light filesystem creations with the tests.

abhishek23tiwari commented 3 months ago

Hi, Can I work on this? If yes, please guide me on how to fix it. Thanks

l0kod commented 3 months ago

Hi @abhishek23tiwari! Yes you can start working this task.

This is not a bug but a test improvement. The first step would be to create minimal filesystems with mkfs.*, then mount them, and after that extend the layout3_fs test variants. All that needs to happen in the fs_test.c. Does it look good?

demonkillerr commented 3 months ago

Hey @l0kod. IRL, the fs needs to be created and mounted against a said volume. For example

mkfs.ext4 /dev/sdaX and mount /dev/sdaX /mnt for example

Can you please point me on how to create the minimal fs with respect to layout3_fs?

l0kod commented 3 months ago

Hey @l0kod.

Hi!

IRL, the fs needs to be created and mounted against a said volume. For example

mkfs.ext4 /dev/sdaX and mount /dev/sdaX /mnt for example

Can you please point me on how to create the minimal fs with respect to layout3_fs?

We can extend FIXTURE(layout3_fs) with some fields to identify the command needed to create a file system, and then in FIXTURE_SETUP(layout3_fs) create this file system accordingly. However, instead of using /dev/sdaX we should use a loop device:

fallocate --length 4M test-ext4.img
mkfs.ext4 -q test-ext4.img
MOLeCULE-Soft commented 3 months ago

Greetings @l0kod, I am an Outreachy applicant and have had 3 patches accepted already. I would like to work on this. Thanks

l0kod commented 3 months ago

Hi @MOLeCULE-Soft, You can work on this. Because several people are interested by this task, everyone should first start with a specific filesystem. We'll see how it goes when patches will be posted on the mailing list.

@abhishek23tiwari @demonkillerr, what is your status? Are you still interested?

demonkillerr commented 3 months ago

Hi @l0kod. I am not part of the Outreachy program, so please feel free to assign it to others. I am a distro maintainer looking at some kernel code 😅.

I am still interested to help regardless.

Tundroid commented 3 months ago

Hi @MOLeCULE-Soft,

Hello @l0kod, sorry I used the wrong account to send the first message, this is my active GitHub account now. I only realised this after your reply. Thanks.

l0kod commented 3 months ago

Hi @l0kod. I am not part of the Outreachy program, so please feel free to assign it to others. I am a distro maintainer looking at some kernel code 😅.

OK

I am still interested to help regardless.

Good! You might be interested by other test tasks. They may be a bit more complex though.

Tundroid commented 3 months ago

Hello @l0kod

I am having issues creating a loop device for ext4.

system("losetup /dev/loop0 test-ext4.img");

Using system above, I get the following error

losetup: /dev/loop0: failed to set up loop device: No such device or address

And when I use

open("/dev/loop0", O_RDWR);

I get an error still. Please, can you direct me on what I am missing.

Thanks in advance

l0kod commented 3 months ago

I am having issues creating a loop device for ext4.

system("losetup /dev/loop0 test-ext4.img");

It might not be required to directly call loseup but only mkfs.*.

Using system above, I get the following error

losetup: /dev/loop0: failed to set up loop device: No such device or address

I guess kernel's CONFIG_BLK_DEV_LOOP is not set.

saashaspace commented 3 months ago

Hello Sir @l0kod,

when we are creating a file system with mkfs.*, do we need to check for any condition where there might be a failure, (say PID = -1)

abhishek23tiwari commented 3 months ago

Hi @MOLeCULE-Soft, You can work on this. Because several people are interested by this task, everyone should first start with a specific filesystem. We'll see how it goes when patches will be posted on the mailing list.

@abhishek23tiwari @demonkillerr, what is your status? Are you still interested?

Hi, because of some reasons, I am not able to continue with the program. And I think you already assigned someone so, I have no issue. :) Happy Coding.

Tundroid commented 2 months ago

Hi @l0kod,

One of the challenges is to cleanly integrate light filesystem creations with the tests.

Can you ellaborate this?

Secondly, I keep getting this error whenever I try to mount the filesystem ext4;

mount: tmp/ext4_mnt: mount failed: Operation not permitted.

Can you please guide me on this?

Thanks

l0kod commented 2 months ago

when we are creating a file system with mkfs.*, do we need to check for any condition where there might be a failure, (say PID = -1)

Yes, all steps required to create a file system must be checked with asserts.

l0kod commented 2 months ago

One of the challenges is to cleanly integrate light filesystem creations with the tests.

Can you ellaborate this?

File system creations should be quick, not take much space (see call to fallocate in my example), and not depend on block devices (except loop devices). They should cleanly integrated with the existing layout3_fs variants.

Secondly, I keep getting this error whenever I try to mount the filesystem ext4;

mount: tmp/ext4_mnt: mount failed: Operation not permitted.

Can you please guide me on this?

You probably need to allow CAP_SYS_ADMIN, see set_cap() and clear_cap() calls.

l0kod commented 2 weeks ago

I guess @Tundroid is not working on this task anymore.