-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mount control #14
Comments
This is useful, thanks for the details. I am working on updating that patch to use the refer logic instead of naively allowing a bind mount. I will update as I make progress. |
Hi @l0kod, I updated the patch to support the same checks as REFER for bind-mounts and wanted to get some feedback on the high-level design. One interesting side-effect is that for the bind-mount to succeed, the source's parent needs to carry the LANDLOCK_ACCESS_FS_MOUNT rule, in addition to the destination directory (i.e. mount point). I think this is OK, as it works the same way for rename and link. For example, if I want to move |
This looks good overall. Thinking more about it, we should probably (re)use
I'm worried about a race conditions in With that in mind, and a clang-formatted code, you can send a first RFC patch series, we'll review it there. Please add at least a few tests for now and propose a set of test scenarios for when we'll be OK with the approach. You can use https://github.com/landlock-lsm/landlock-test-tools on top of my |
Doesn’t this mean in practice we are also requiring
I think I found a place where we can add a hook for bind mount after the path is evaluated to eliminate the race. Will work on the tests and preparing for RFC patches. |
Because of the way mounts propagate by default, we should only allow bind mounts on private mounts if the source doesn't have We should also be careful to only create mount point that are not less-restrictive than the source (e.g. removing For mount operation, no
Looking at it again with an up-to-date mount utility, the new mount syscalls (e.g.
Great, we can continue the discussion there. |
Well, to allow a bind mount on a shared mount point, it's not the source that should have However, if the destination mount point is private, we can look for |
[ Upstream commit a699781 ] A sysfs reader can race with a device reset or removal, attempting to read device state when the device is not actually present. eg: [exception RIP: qed_get_current_link+17] #8 [ffffb9e4f2907c48] qede_get_link_ksettings at ffffffffc07a994a [qede] #9 [ffffb9e4f2907cd8] __rh_call_get_link_ksettings at ffffffff992b01a3 #10 [ffffb9e4f2907d38] __ethtool_get_link_ksettings at ffffffff992b04e4 #11 [ffffb9e4f2907d90] duplex_show at ffffffff99260300 #12 [ffffb9e4f2907e38] dev_attr_show at ffffffff9905a01c #13 [ffffb9e4f2907e50] sysfs_kf_seq_show at ffffffff98e0145b #14 [ffffb9e4f2907e68] seq_read at ffffffff98d902e3 #15 [ffffb9e4f2907ec8] vfs_read at ffffffff98d657d1 #16 [ffffb9e4f2907f00] ksys_read at ffffffff98d65c3f #17 [ffffb9e4f2907f38] do_syscall_64 at ffffffff98a052fb crash> struct net_device.state ffff9a9d21336000 state = 5, state 5 is __LINK_STATE_START (0b1) and __LINK_STATE_NOCARRIER (0b100). The device is not present, note lack of __LINK_STATE_PRESENT (0b10). This is the same sort of panic as observed in commit 4224cfd ("net-sysfs: add check for netdevice being present to speed_show"). There are many other callers of __ethtool_get_link_ksettings() which don't have a device presence check. Move this check into ethtool to protect all callers. Fixes: d519e17 ("net: export device speed and duplex via sysfs") Fixes: 4224cfd ("net-sysfs: add check for netdevice being present to speed_show") Signed-off-by: Jamie Bainbridge <[email protected]> Link: https://patch.msgid.link/8bae218864beaa44ed01628140475b9bf641c5b0.1724393671.git.jamie.bainbridge@gmail.com Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
@supersonnic, what is the status of your work? Do you need some help? This looks ready for an RFC: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/5722641 |
The main issue I'm having right now is that I cannot get LandLock to only accept the bind-mount if the In other words, the bug in the patch is that it allows mounts even when one of the mount point parent directories has the rule. This is a problem, as aloowing bind-mounts under an existing bind-mount can open a pathway for policy bypass. This is an example of a policy bypass that can be achieved if we allow inheritance of the mount point rule. Consider the following directory structure. First we bind-mount I considered intercepting the propagate system call, but did not have success with that, so I think the best way to mitigate this is to modify the rule checking behavior for mount point, such that it cannot be inherited, which brings us back the issue I'm having with that patch. I just need a way to collect and check the rules carried by a single directory. |
To avoid filesystem (FS) security policy bypass, a landlocked process with FS restrictions cannot do any FS topology changes (see d722036), which include any mount calls.
Even with FS restrictions, it would be useful for some use cases to be able to safely do new mount and umount.
The main issue I see is that we may want to allow a set of accesses on the newly mount points, independently from the existing
path_beneath
rules because the new mount point would overlap part of the initial file hierarchy. For this reason, I think we could have a new type of rule dedicated to mount access rights, something likeLANDLOCK_RULE_MOUNT
. With a dedicated attr struct, probably withlandlock_path_beneath_attr
's equivalent fields, we'll be able to configure a whole mount point and enforce specific options such asro
andnoexec
. I guess the current LSM hooks should be enough.Because a mount would change the file hierarchy, we would also need a dedicated
LANDLOCK_ACCESS_FS_MOUNT
right to control this change. Everything beneath such mount point will get the source'sLANDLOCK_RULE_MOUNT
properties/restrictions.For bind mounts, I think we can follow the same checks as for
LANDLOCK_ACCESS_FS_REFER
with theLANDLOCK_ACCESS_FS_MOUNT
(which could then be used for source and destination).This approach should also enable to allow a service to do mounts without giving it the right to access them.
I suggest to start with the bind mount case and then incrementally add support for the block device mount case (and the new related rule type).
I now think unmounts should never be denied though, so we may want to add a new flag at the ruleset level to only manage compatibility.
Related chromeOS CL: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/5077507
The text was updated successfully, but these errors were encountered: