Skip to content
Commit 547b3aa4 authored by John Fastabend's avatar John Fastabend Committed by Alexei Starovoitov
Browse files

bpf: sockmap, error path can not release psock in multi-map case



The current code, in the error path of sock_hash_ctx_update_elem,
checks if the sock has a psock in the user data and if so decrements
the reference count of the psock. However, if the error happens early
in the error path we may have never incremented the psock reference
count and if the psock exists because the sock is in another map then
we may inadvertently decrement the reference count.

Fix this by making the error path only call smap_release_sock if the
error happens after the increment.

Reported-by: default avatar <syzbot+d464d2c20c717ef5a6a8@syzkaller.appspotmail.com>
Fixes: 81110384 ("bpf: sockmap, add hash map support")
Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent c48424d9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment