Skip to content

Commit 6fb003e

Browse files
nixiaominggregkh
authored andcommitted
nfc: fix refcount leak in llcp_sock_bind()
commit c33b1cc 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: c7aa122 ("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>
1 parent 1175577 commit 6fb003e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎net/nfc/llcp_sock.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
108108
llcp_sock->service_name_len,
109109
GFP_KERNEL);
110110
if (!llcp_sock->service_name) {
111+
nfc_llcp_local_put(llcp_sock->local);
111112
ret = -ENOMEM;
112113
goto put_dev;
113114
}
114115
llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock);
115116
if (llcp_sock->ssap == LLCP_SAP_MAX) {
117+
nfc_llcp_local_put(llcp_sock->local);
116118
kfree(llcp_sock->service_name);
117119
llcp_sock->service_name = NULL;
118120
ret = -EADDRINUSE;

0 commit comments

Comments
 (0)