]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: sockmap, error path can not release psock in multi-map case
authorJohn Fastabend <john.fastabend@gmail.com>
Thu, 5 Jul 2018 15:05:56 +0000 (08:05 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 7 Jul 2018 22:16:58 +0000 (15:16 -0700)
commit00fd173c4278d113f7545080011c5447c5d4e56d
treee691f1e7a7ce545c4796040583e2a813fb70fa46
parent218ed3b963839cdb9a039778d520389b4d1aeca2
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: syzbot+d464d2c20c717ef5a6a8@syzkaller.appspotmail.com
Fixes: 11052050f9ca ("bpf: sockmap, add hash map support")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/sockmap.c