nfc: fix refcount leak in llcp_sock_bind()
authorXiaoming Ni <nixiaoming@huawei.com>
Thu, 25 Mar 2021 03:51:10 +0000 (11:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:41:56 +0000 (08:41 +0200)
commit6fb003e5ae18d8cda4c8a1175d9dd8db12bec049
treed4810388178256f857ded70ad5f29f2c2c36a773
parent1175577119741a1eb26369678f09ccd312a178a1
nfc: fix refcount leak in llcp_sock_bind()

commit c33b1cc62ac05c1dbb1cdafe2eb66da01c76ca8d upstream.

nfc_llcp_local_get() is invoked in llcp_sock_bind(),
but nfc_llcp_local_put() is not invoked in subsequent failure branches.
As a result, refcount leakage occurs.
To fix it, add calling nfc_llcp_local_put().

fix CVE-2020-25670
Fixes: c7aa12252f51 ("NFC: Take a reference on the LLCP local pointer when creating a socket")
Reported-by: "kiyin(尹亮)" <kiyin@tencent.com>
Link: https://www.openwall.com/lists/oss-security/2020/11/01/1
Cc: <stable@vger.kernel.org> #v3.6
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/nfc/llcp_sock.c