mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
bpf: Move LSM trampoline unlink into bpf_cgroup_link_auto_detach()
Move the LSM trampoline unlink into bpf_cgroup_link_auto_detach(). The purpose is to consolidate the auto_detach cleanup logic. It prepares for the upcoming struct_ops cgroup attachment patch where bpf_cgroup_link_auto_detach() will need to handle the struct_ops case (link->map != NULL). This is a no-op change. Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://patch.msgid.link/20260917200542.3689605-8-ameryhung@gmail.com
This commit is contained in:
parent
4d71b3e082
commit
2ef54525d2
|
|
@ -313,6 +313,8 @@ static void bpf_cgroup_storages_link(struct bpf_cgroup_storage *storages[],
|
|||
*/
|
||||
static void bpf_cgroup_link_auto_detach(struct bpf_cgroup_link *link)
|
||||
{
|
||||
if (link->link.prog->expected_attach_type == BPF_LSM_CGROUP)
|
||||
bpf_trampoline_unlink_cgroup_shim(link->link.prog);
|
||||
cgroup_put(link->cgroup);
|
||||
link->cgroup = NULL;
|
||||
}
|
||||
|
|
@ -346,11 +348,8 @@ static void cgroup_bpf_release(struct work_struct *work)
|
|||
bpf_trampoline_unlink_cgroup_shim(pl->prog);
|
||||
bpf_prog_put(pl->prog);
|
||||
}
|
||||
if (pl->link) {
|
||||
if (pl->link->link.prog->expected_attach_type == BPF_LSM_CGROUP)
|
||||
bpf_trampoline_unlink_cgroup_shim(pl->link->link.prog);
|
||||
if (pl->link)
|
||||
bpf_cgroup_link_auto_detach(pl->link);
|
||||
}
|
||||
kfree(pl);
|
||||
static_branch_dec(&cgroup_bpf_enabled_key[atype]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user