|
Takashi Iwai |
21864e |
From c33b1cc62ac05c1dbb1cdafe2eb66da01c76ca8d Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
21864e |
From: Xiaoming Ni <nixiaoming@huawei.com>
|
|
Takashi Iwai |
21864e |
Date: Thu, 25 Mar 2021 11:51:10 +0800
|
|
Takashi Iwai |
21864e |
Subject: [PATCH] nfc: fix refcount leak in llcp_sock_bind()
|
|
Takashi Iwai |
21864e |
Mime-version: 1.0
|
|
Takashi Iwai |
21864e |
Content-type: text/plain; charset=UTF-8
|
|
Takashi Iwai |
21864e |
Content-transfer-encoding: 8bit
|
|
Takashi Iwai |
21864e |
Git-commit: c33b1cc62ac05c1dbb1cdafe2eb66da01c76ca8d
|
|
Takashi Iwai |
21864e |
Patch-mainline: v5.12-rc7
|
|
Takashi Iwai |
21864e |
References: CVE-2020-25670 bsc#1178181
|
|
Takashi Iwai |
21864e |
|
|
Takashi Iwai |
21864e |
nfc_llcp_local_get() is invoked in llcp_sock_bind(),
|
|
Takashi Iwai |
21864e |
but nfc_llcp_local_put() is not invoked in subsequent failure branches.
|
|
Takashi Iwai |
21864e |
As a result, refcount leakage occurs.
|
|
Takashi Iwai |
21864e |
To fix it, add calling nfc_llcp_local_put().
|
|
Takashi Iwai |
21864e |
|
|
Takashi Iwai |
21864e |
fix CVE-2020-25670
|
|
Takashi Iwai |
21864e |
|
|
Takashi Iwai |
21864e |
Fixes: c7aa12252f51 ("NFC: Take a reference on the LLCP local pointer when creating a socket")
|
|
Takashi Iwai |
21864e |
Reported-by: "kiyin(尹亮)" <kiyin@tencent.com>
|
|
Takashi Iwai |
21864e |
Link: https://www.openwall.com/lists/oss-security/2020/11/01/1
|
|
Takashi Iwai |
21864e |
Cc: <stable@vger.kernel.org> #v3.6
|
|
Takashi Iwai |
21864e |
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
|
|
Takashi Iwai |
21864e |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
Takashi Iwai |
21864e |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
21864e |
|
|
Takashi Iwai |
21864e |
---
|
|
Takashi Iwai |
21864e |
net/nfc/llcp_sock.c | 2 ++
|
|
Takashi Iwai |
21864e |
1 file changed, 2 insertions(+)
|
|
Takashi Iwai |
21864e |
|
|
Takashi Iwai |
21864e |
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
|
|
Takashi Iwai |
21864e |
index d257ed3b732a..68832ee4b9f8 100644
|
|
Takashi Iwai |
21864e |
--- a/net/nfc/llcp_sock.c
|
|
Takashi Iwai |
21864e |
+++ b/net/nfc/llcp_sock.c
|
|
Takashi Iwai |
21864e |
@@ -108,11 +108,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
|
|
Takashi Iwai |
21864e |
llcp_sock->service_name_len,
|
|
Takashi Iwai |
21864e |
GFP_KERNEL);
|
|
Takashi Iwai |
21864e |
if (!llcp_sock->service_name) {
|
|
Takashi Iwai |
21864e |
+ nfc_llcp_local_put(llcp_sock->local);
|
|
Takashi Iwai |
21864e |
ret = -ENOMEM;
|
|
Takashi Iwai |
21864e |
goto put_dev;
|
|
Takashi Iwai |
21864e |
}
|
|
Takashi Iwai |
21864e |
llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock);
|
|
Takashi Iwai |
21864e |
if (llcp_sock->ssap == LLCP_SAP_MAX) {
|
|
Takashi Iwai |
21864e |
+ nfc_llcp_local_put(llcp_sock->local);
|
|
Takashi Iwai |
21864e |
kfree(llcp_sock->service_name);
|
|
Takashi Iwai |
21864e |
llcp_sock->service_name = NULL;
|
|
Takashi Iwai |
21864e |
ret = -EADDRINUSE;
|
|
Takashi Iwai |
21864e |
--
|
|
Takashi Iwai |
21864e |
2.26.2
|
|
Takashi Iwai |
21864e |
|