854277e2 | 05-Feb-2025 |
Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com> |
landlock: Fix non-TCP sockets restriction
Use sk_is_tcp() to check if socket is TCP in bind(2) and connect(2) hooks.
SMC, MPTCP, SCTP protocols are currently restricted by TCP access rights. The p
landlock: Fix non-TCP sockets restriction
Use sk_is_tcp() to check if socket is TCP in bind(2) and connect(2) hooks.
SMC, MPTCP, SCTP protocols are currently restricted by TCP access rights. The purpose of TCP access rights is to provide control over ports that can be used by userland to establish a TCP connection. Therefore, it is incorrect to deny bind(2) and connect(2) requests for a socket of another protocol.
However, SMC, MPTCP and RDS implementations use TCP internal sockets to establish communication or even to exchange packets over a TCP connection [1]. Landlock rules that configure bind(2) and connect(2) usage for TCP sockets should not cover requests for sockets of such protocols. These protocols have different set of security issues and security properties, therefore, it is necessary to provide the userland with the ability to distinguish between them (eg. [2]).
Control over TCP connection used by other protocols can be achieved with upcoming support of socket creation control [3].
[1] https://lore.kernel.org/all/62336067-18c2-3493-d0ec-6dd6a6d3a1b5@huawei-partners.com/ [2] https://lore.kernel.org/all/20241204.fahVio7eicim@digikod.net/ [3] https://lore.kernel.org/all/20240904104824.1844082-1-ivanov.mikhail1@huawei-partners.com/
Closes: https://github.com/landlock-lsm/linux/issues/40 Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect") Signed-off-by: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com> Link: https://lore.kernel.org/r/20250205093651.1424339-2-ivanov.mikhail1@huawei-partners.com [mic: Format commit message to 72 columns] Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
d617f0d7 | 08-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Optimize file path walks and prepare for audit support
Always synchronize access_masked_parent* with access_request_parent* according to allowed_parent*. This is required for audit suppor
landlock: Optimize file path walks and prepare for audit support
Always synchronize access_masked_parent* with access_request_parent* according to allowed_parent*. This is required for audit support to be able to get back to the reason of denial.
In a rename/link action, instead of always checking a rule two times for the same parent directory of the source and the destination files, only check it when an action on a child was not already allowed. This also enables us to keep consistent allowed_parent* status, which is required to get back to the reason of denial.
For internal mount points, only upgrade allowed_parent* to true but do not wrongfully set both of them to false otherwise. This is also required to get back to the reason of denial.
This does not impact the current behavior but slightly optimize code and prepare for audit support that needs to know the exact reason why an access was denied.
Cc: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250108154338.1129069-14-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
058518c2 | 08-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Align partial refer access checks with final ones
Fix a logical issue that could have been visible if the source or the destination of a rename/link action was allowed for either the sourc
landlock: Align partial refer access checks with final ones
Fix a logical issue that could have been visible if the source or the destination of a rename/link action was allowed for either the source or the destination but not both. However, this logical bug is unreachable because either: - the rename/link action is allowed by the access rights tied to the same mount point (without relying on access rights in a parent mount point) and the access request is allowed (i.e. allow_parent1 and allow_parent2 are true in current_check_refer_path), - or a common rule in a parent mount point updates the access check for the source and the destination (cf. is_access_to_paths_allowed).
See the following layout1.refer_part_mount_tree_is_allowed test that work with and without this fix.
This fix does not impact current code but it is required for the audit support.
Cc: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250108154338.1129069-12-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
d6c7cf84 | 08-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Simplify initially denied access rights
Upgrade domain's handled access masks when creating a domain from a ruleset, instead of converting them at runtime. This is more consistent and hel
landlock: Simplify initially denied access rights
Upgrade domain's handled access masks when creating a domain from a ruleset, instead of converting them at runtime. This is more consistent and helps with audit support.
Cc: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250108154338.1129069-7-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
622e2f59 | 08-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Move access types
Move LANDLOCK_ACCESS_FS_INITIALLY_DENIED, access_mask_t, struct access_mask, and struct access_masks_all to a dedicated access.h file.
Rename LANDLOCK_ACCESS_FS_INITIALL
landlock: Move access types
Move LANDLOCK_ACCESS_FS_INITIALLY_DENIED, access_mask_t, struct access_mask, and struct access_masks_all to a dedicated access.h file.
Rename LANDLOCK_ACCESS_FS_INITIALLY_DENIED to _LANDLOCK_ACCESS_FS_INITIALLY_DENIED to make it clear that it's not part of UAPI. Add some newlines when appropriate.
This file will be extended with following commits, and it will help to avoid dependency loops.
Cc: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250108154338.1129069-6-mic@digikod.net [mic: Fix rebase conflict because of the new cleanup headers] Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
924f4403 | 08-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Factor out check_access_path()
Merge check_access_path() into current_check_access_path() and make hook_path_mknod() use it.
Cc: Günther Noack <gnoack@google.com> Link: https://lore.kerne
landlock: Factor out check_access_path()
Merge check_access_path() into current_check_access_path() and make hook_path_mknod() use it.
Cc: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250108154338.1129069-4-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
16a6f4d3 | 13-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Use scoped guards for ruleset in landlock_add_rule()
Simplify error handling by replacing goto statements with automatic calls to landlock_put_ruleset() when going out of scope.
This chan
landlock: Use scoped guards for ruleset in landlock_add_rule()
Simplify error handling by replacing goto statements with automatic calls to landlock_put_ruleset() when going out of scope.
This change depends on the TCP support.
Cc: Konstantin Meskhidze <konstantin.meskhidze@huawei.com> Cc: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com> Reviewed-by: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250113161112.452505-3-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
d32f79a5 | 13-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Use scoped guards for ruleset
Simplify error handling by replacing goto statements with automatic calls to landlock_put_ruleset() when going out of scope.
This change will be easy to back
landlock: Use scoped guards for ruleset
Simplify error handling by replacing goto statements with automatic calls to landlock_put_ruleset() when going out of scope.
This change will be easy to backport to v6.6 if needed, only the kernel.h include line conflicts. As for any other similar changes, we should be careful when backporting without goto statements.
Add missing include file.
Reviewed-by: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20250113161112.452505-2-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
25ccc75f | 10-Jan-2025 |
Mickaël Salaün <mic@digikod.net> |
landlock: Constify get_mode_access()
Use __attribute_const__ for get_mode_access().
Reviewed-by: Günther Noack <gnoack3000@gmail.com> Link: https://lore.kernel.org/r/20250110153918.241810-2-mic@dig
landlock: Constify get_mode_access()
Use __attribute_const__ for get_mode_access().
Reviewed-by: Günther Noack <gnoack3000@gmail.com> Link: https://lore.kernel.org/r/20250110153918.241810-2-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
03197e40 | 09-Nov-2024 |
Mickaël Salaün <mic@digikod.net> |
landlock: Optimize scope enforcement
Do not walk through the domain hierarchy when the required scope is not supported by this domain. This is the same approach as for filesystem and network restri
landlock: Optimize scope enforcement
Do not walk through the domain hierarchy when the required scope is not supported by this domain. This is the same approach as for filesystem and network restrictions.
Cc: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com> Cc: Tahera Fahimi <fahimitahera@gmail.com> Reviewed-by: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20241109110856.222842-4-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
8376226e | 09-Nov-2024 |
Mickaël Salaün <mic@digikod.net> |
landlock: Refactor network access mask management
Replace get_raw_handled_net_accesses() and get_current_net_domain() with a call to landlock_get_applicable_domain().
Cc: Konstantin Meskhidze <kons
landlock: Refactor network access mask management
Replace get_raw_handled_net_accesses() and get_current_net_domain() with a call to landlock_get_applicable_domain().
Cc: Konstantin Meskhidze <konstantin.meskhidze@huawei.com> Cc: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com> Reviewed-by: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20241109110856.222842-3-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|
54a6e6bb | 06-Sep-2024 |
Tahera Fahimi <fahimitahera@gmail.com> |
landlock: Add signal scoping
Currently, a sandbox process is not restricted to sending a signal (e.g. SIGKILL) to a process outside the sandbox environment. The ability to send a signal for a sandb
landlock: Add signal scoping
Currently, a sandbox process is not restricted to sending a signal (e.g. SIGKILL) to a process outside the sandbox environment. The ability to send a signal for a sandboxed process should be scoped the same way abstract UNIX sockets are scoped. Therefore, we extend the "scoped" field in a ruleset with LANDLOCK_SCOPE_SIGNAL to specify that a ruleset will deny sending any signal from within a sandbox process to its parent (i.e. any parent sandbox or non-sandboxed processes).
This patch adds file_set_fowner and file_free_security hooks to set and release a pointer to the file owner's domain. This pointer, fown_domain in landlock_file_security will be used in file_send_sigiotask to check if the process can send a signal.
The ruleset_with_unknown_scope test is updated to support LANDLOCK_SCOPE_SIGNAL.
This depends on two new changes: - commit 1934b212615d ("file: reclaim 24 bytes from f_owner"): replace container_of(fown, struct file, f_owner) with fown->file . - commit 26f204380a3c ("fs: Fix file_set_fowner LSM hook inconsistencies"): lock before calling the hook.
Signed-off-by: Tahera Fahimi <fahimitahera@gmail.com> Closes: https://github.com/landlock-lsm/linux/issues/8 Link: https://lore.kernel.org/r/df2b4f880a2ed3042992689a793ea0951f6798a5.1725657727.git.fahimitahera@gmail.com [mic: Update landlock_get_current_domain()'s return type, improve and fix locking in hook_file_set_fowner(), simplify and fix sleepable call and locking issue in hook_file_send_sigiotask() and rebase on the latest VFS tree, simplify hook_task_kill() and quickly return when not sandboxed, improve comments, rename LANDLOCK_SCOPED_SIGNAL] Co-developed-by: Mickaël Salaün <mic@digikod.net> Signed-off-by: Mickaël Salaün <mic@digikod.net>
show more ...
|