Skip to content

Commit 0c047ec

Browse files
jsitnickiAlexei Starovoitov
authored andcommitted
bpf, cgroup: Return ENOLINK for auto-detached links on update
Failure to update a bpf_link because it has been auto-detached by a dying cgroup currently results in EINVAL error, even though the arguments passed to bpf() syscall are not wrong. bpf_links attaching to netns in this case will return ENOLINK, which carries the message that the link is no longer attached to anything. Change cgroup bpf_links to do the same to keep the uAPI errors consistent. Fixes: 0c991eb ("bpf: Implement bpf_prog replacement for an active bpf_cgroup_link") Suggested-by: Lorenz Bauer <[email protected]> Signed-off-by: Jakub Sitnicki <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 7f045a4 commit 0c047ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static int cgroup_bpf_replace(struct bpf_link *link, struct bpf_prog *new_prog,
595595
mutex_lock(&cgroup_mutex);
596596
/* link might have been auto-released by dying cgroup, so fail */
597597
if (!cg_link->cgroup) {
598-
ret = -EINVAL;
598+
ret = -ENOLINK;
599599
goto out_unlock;
600600
}
601601
if (old_prog && link->prog != old_prog) {

0 commit comments

Comments
 (0)