nfc: fix refcount leak in llcp_sock_connect()
authorXiaoming Ni <nixiaoming@huawei.com>
Thu, 25 Mar 2021 03:51:11 +0000 (11:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Apr 2021 09:57:47 +0000 (11:57 +0200)
commitb1d5c07a3b597766bbf5bf61083cd65e72034144
treecba7cca3f86f4c4393937f3fdfe0501fdabdd11f
parent538a6ff11516d38a61e237d2d2dc04c30c845fbe
nfc: fix refcount leak in llcp_sock_connect()

commit 8a4cd82d62b5ec7e5482333a72b58a4eea4979f0 upstream.

nfc_llcp_local_get() is invoked in llcp_sock_connect(),
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-25671
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