Skip to content
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

Restrict executing on memfd #37

Open
sisungo opened this issue Jun 29, 2024 · 5 comments
Open

Restrict executing on memfd #37

sisungo opened this issue Jun 29, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@sisungo
Copy link

sisungo commented Jun 29, 2024

We can run executable files that are only given read but not execute access by copying them into a memfd and then call fexecve on the file descriptor. Should we restrict this?

@l0kod
Copy link
Member

l0kod commented Jul 2, 2024

The initial goal of Landlock is to control access to data, but yes, it makes sense to have more control over an execution environment.

We could leverage the scoped field in struct landlock_ruleset_attr (see #7) and add a dedicated flag to deny memfd execution if it was created in a Landlock domain with such flag set.

@l0kod l0kod added enhancement New feature or request good first issue Good for newcomers labels Jul 2, 2024
@l0kod
Copy link
Member

l0kod commented Jul 8, 2024

See chromeOS's memfd restriction: chromiumos_bprm_creds_for_exec().

@l0kod
Copy link
Member

l0kod commented Jul 18, 2024

A more generic approach would be to deny any memory from being mapped as executable, except when mmaping a file with the LANDLOCK_ACCESS_FS_EXECUTE right. This can be implemented with security_mmap_file() and security_file_mprotect().

@sisungo
Copy link
Author

sisungo commented Jul 18, 2024

A more generic approach would be to deny any memory from being mapped as executable, except when mmaping a file with the LANDLOCK_ACCESS_FS_EXECUTE right. This can be implemented with security_mmap_file() and security_file_mprotect().

That is more generic and powerful, indeed.

@l0kod
Copy link
Member

l0kod commented Jul 23, 2024

Such an implementation would also change Landlock's hook_file_alloc_security() to remove the LANDLOCK_ACCESS_FS_EXECUTE right by default (when the caller's domain enforces such restriction). A new implementation of the security_bprm_creds_for_exec() hook would then check each FD's executability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

2 participants