Commit c33b1cc6 authored by Xiaoming Ni's avatar Xiaoming Ni Committed by David S. Miller

nfc: fix refcount leak in llcp_sock_bind()

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: c7aa1225 ("NFC: Take a reference on the LLCP local pointer when creating a socket")
Reported-by: default avatar"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: default avatarXiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d7513508
...@@ -108,11 +108,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) ...@@ -108,11 +108,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
llcp_sock->service_name_len, llcp_sock->service_name_len,
GFP_KERNEL); GFP_KERNEL);
if (!llcp_sock->service_name) { if (!llcp_sock->service_name) {
nfc_llcp_local_put(llcp_sock->local);
ret = -ENOMEM; ret = -ENOMEM;
goto put_dev; goto put_dev;
} }
llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock);
if (llcp_sock->ssap == LLCP_SAP_MAX) { if (llcp_sock->ssap == LLCP_SAP_MAX) {
nfc_llcp_local_put(llcp_sock->local);
kfree(llcp_sock->service_name); kfree(llcp_sock->service_name);
llcp_sock->service_name = NULL; llcp_sock->service_name = NULL;
ret = -EADDRINUSE; ret = -EADDRINUSE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment