Skip to content

Commit 09a3dac

Browse files
iamkafaiAlexei Starovoitov
authored andcommitted
bpf: Fix NULL dereference in bpf_task_storage
In bpf_pid_task_storage_update_elem(), it missed to test the !task_storage_ptr(task) which then could trigger a NULL pointer exception in bpf_local_storage_update(). Fixes: 4cf1bc1 ("bpf: Implement task local storage") Signed-off-by: Martin KaFai Lau <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Tested-by: Roman Gushchin <[email protected]> Acked-by: KP Singh <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 8378788 commit 09a3dac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/bpf_task_storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static int bpf_pid_task_storage_update_elem(struct bpf_map *map, void *key,
150150
*/
151151
WARN_ON_ONCE(!rcu_read_lock_held());
152152
task = pid_task(pid, PIDTYPE_PID);
153-
if (!task) {
153+
if (!task || !task_storage_ptr(task)) {
154154
err = -ENOENT;
155155
goto out;
156156
}

0 commit comments

Comments
 (0)