You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @l0kod,
I start working on this, and read almost all of the related docs & explanations :)
quick question, besides following the landlock logic from task.c (which is ptrace.c in staging branch) and scope changes that should apply to net.c, do we need to modify any other file?
Hi @l0kod, I start working on this, and read almost all of the related docs & explanations :)
Great!
besides following the landlock logic from task.c (which is ptrace.c in staging branch) and scope changes that should apply to net.c, do we need to modify any other file?
I think most changes should be in task.c/ptrace.c. The net.c file is dedicated to network rule management (only TCP bind/connect for now), but the abstract unix socket restrictions should be implemented as scopes like for ptrace restrictions (e.g. no new Landlock rule type but only a ruleset's flag, no sockaddr parsing...). Moreover, I consider abstract unix sockets to be more an IPC mechanism rather than a network feature. task.c contains the main helpers that should be used (and extended): task_is_scoped() and domain_scope_le().
About the flag design, see #8 (comment). Updating this interface should lead you to the other files that will need some changes.
Thanks for your comments! Based on you suggested, I had a look; please correct me if I am wrong.
First I have to add a struct field to the landlock_ruleset in landlock/ruleset.h (a struct field same as hierarchy which is used for ptrace). Then I should edit the "landlock/ptrace.c" and add landlock_hooks for unix_stream_connect and unix_may_send and write the respective helpers (same thing we have for ptrace_traceme and ptrace_access_check for ptrace).
Looks good! One important thing to keep in mind is that because abstract unix socket scoping will be optional, you might need to implement new checks in the current domain_scope_le() helper and related data structures/calls.
BTW, the rename of ptrace.c to task.c is now merged: 35e886e
I'm assigning this issue to you. Please regularly update it with your progress. This doesn't need to be long but just enough to make sure you are not blocked.
@l0kod, I have a quick question:
Since the input of hook_unix_stream_connect are struct sock *const sock, struct sock *const other, and struct sock *const newsk, how can we map a sock struct to a task_struct? (because it is specified in here that we want to scope the abstract unix socket according to a landlock domain, and we can get the landlock_ruleset through landlock_get_task_domainfunction)
Activity
[-]Abstract socket control[/-][+]Abstract unix socket control[/+]tahifahimi commentedon Mar 13, 2024
Hi @l0kod,
I start working on this, and read almost all of the related docs & explanations :)
quick question, besides following the landlock logic from
task.c(which isptrace.cin staging branch) and scope changes that should apply tonet.c, do we need to modify any other file?l0kod commentedon Mar 13, 2024
Hi @tahifahimi,
Great!
I think most changes should be in
task.c/ptrace.c. Thenet.cfile is dedicated to network rule management (only TCP bind/connect for now), but the abstract unix socket restrictions should be implemented as scopes like for ptrace restrictions (e.g. no new Landlock rule type but only a ruleset's flag, no sockaddr parsing...). Moreover, I consider abstract unix sockets to be more an IPC mechanism rather than a network feature.task.ccontains the main helpers that should be used (and extended):task_is_scoped()anddomain_scope_le().About the flag design, see #8 (comment). Updating this interface should lead you to the other files that will need some changes.
tahifahimi commentedon Mar 15, 2024
Thanks for your comments! Based on you suggested, I had a look; please correct me if I am wrong.
First I have to add a struct field to the
landlock_rulesetin landlock/ruleset.h (a struct field same ashierarchywhich is used for ptrace). Then I should edit the "landlock/ptrace.c" and add landlock_hooks forunix_stream_connectandunix_may_sendand write the respective helpers (same thing we have forptrace_tracemeandptrace_access_checkfor ptrace).l0kod commentedon Mar 15, 2024
Looks good! One important thing to keep in mind is that because abstract unix socket scoping will be optional, you might need to implement new checks in the current
domain_scope_le()helper and related data structures/calls.BTW, the rename of
ptrace.ctotask.cis now merged: 35e886el0kod commentedon Mar 15, 2024
I'm assigning this issue to you. Please regularly update it with your progress. This doesn't need to be long but just enough to make sure you are not blocked.
tahifahimi commentedon Mar 20, 2024
@l0kod, I have a quick question:
Since the input of
hook_unix_stream_connectarestruct sock *const sock,struct sock *const other, andstruct sock *const newsk, how can we map asock structto atask_struct? (because it is specified in here that we want to scope the abstract unix socket according to a landlock domain, and we can get thelandlock_rulesetthroughlandlock_get_task_domainfunction)23 remaining items
KVM: Use dedicated mutex to protect kvm_usage_count to avoid deadlock
perf hist: Update hist symbol when updating maps
perf report: Fix segfault when 'sym' sort key is not used
mm: vmscan: account for free pages to prevent infinite Loop in thrott…
perf trace: Fix runtime error of index out of bounds
perf trace: Fix runtime error of index out of bounds
landlock: Add abstract UNIX socket scoping
ice: fix NULL pointer dereference in ice_reset_all_vfs()
ice: fix NULL pointer dereference in ice_reset_all_vfs()
libbpf: Fix UAF in strset__add_str()
libbpf: Fix UAF in strset__add_str()
net/sched: act_tunnel_key: Defer dst_release to RCU callback
net/sched: act_tunnel_key: Defer dst_release to RCU callback
sched/cache: Decouple sched_cache_group from mm to fix UAF
sched/cache: Introduce task_struct->sched_cache_grp to fix UAF