Skip to content

Commit 7bbc5ae

Browse files
ameryhungKernel Patches Daemon
authored andcommitted
bpf: Make sure all tail call callers use cgroup storage if the owner does
Mitigate a possible NULL pointer dereference in bpf_get_local_storage() by requiring all callers to use cgroup storage if the owner does. Cgroup storage is allocated lazily when attaching a cgroup bpf program. With tail call, it is possible for a callee BPF program to see a NULL storage pointer if the caller prorgam does not use cgroup storage. Reported-by: Yinhao Hu <[email protected]> Reported-by: Kaiyan Mei <[email protected]> Reported-by: Dongliang Mu <[email protected]> Closes: https://lore.kernel.org/bpf/[email protected]/ Signed-off-by: Amery Hung <[email protected]>
1 parent db65bfd commit 7bbc5ae

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/bpf/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,8 +2382,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
23822382
break;
23832383
cookie = aux->cgroup_storage[i] ?
23842384
aux->cgroup_storage[i]->cookie : 0;
2385-
ret = map->owner->storage_cookie[i] == cookie ||
2386-
!cookie;
2385+
ret = map->owner->storage_cookie[i] == cookie;
23872386
}
23882387
if (ret &&
23892388
map->owner->attach_func_proto != aux->attach_func_proto) {

0 commit comments

Comments
 (0)