fix: fix hardlinking between different directories.#56
Open
zicklag wants to merge 1 commit into
Open
Conversation
Fixes a bug due to the kernel's special handling of the FSRefer access. Previously landrun would restrict file paths with one call to RestrictPaths() and restrict network access with a second call to RestrictNet(). The issue is that when we call RestrictNet(), it carries with it an implicit restriction on the FSRefer access. According to the kernel docs on FSRefer: > This is the only access right which is denied by default by any ruleset, > even if the right is not specified as handled at ruleset creation time. > The only way to make a ruleset grant this right is to explicitly allow it > for a specific directory by adding a matching rule to the ruleset. We get around this by making a single call to Restrict() instead of two separate calls, unless either the filesystem or network are unrestricted, in which case we just restrict the one that is still restricted with RestrictPaths() or RestrictNet().
Author
|
Haha, well, cool. I didn't realize there was already a fix for it. 🙃 |
|
When I read the description I remembered some PR was already talking about two layers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug due to the kernel's special handling of the FSRefer access.
Previously landrun would restrict file paths with one call to
RestrictPaths()and restrict network access with a second call toRestrictNet().The issue is that when we call
RestrictNet(), it carries with it an implicit restriction on the FSRefer access. According to the kernel docs on FSRefer:We get around this by making a single call to Restrict() instead of two separate calls, unless either the filesystem or network are unrestricted, in which case we just restrict the one that is still restricted with RestrictPaths() or RestrictNet().
Interestingly, even before this PR, running landrun with
--unrestrestricted-networkactually fixes the hardlink issue because it doesn't create the second landlock layer for the network access.AI usage disclosure: DeepSeek v4 Flash was used to find the root cause of the issue. I have my entire chat transcript public for transparency. You can see exactly how I prompted it, and all the models tool calls, thinking, etc. Nothing was redacted. By the end of the session I believe I understand the fix, and why it works, and I sign off on the code as having put my own full due dilligence into making sure it made sense to me and lined up with the kernel documentation as well as my own tests.
Fixes: #55