From: Xiaoming Ni <nixiaoming@huawei.com>
To: <linux-kernel@vger.kernel.org>, <kiyin@tencent.com>,
<stable@vger.kernel.org>, <gregkh@linuxfoundation.org>,
<sameo@linux.intel.com>, <linville@tuxdriver.com>,
<davem@davemloft.net>, <kuba@kernel.org>, <mkl@pengutronix.de>,
<stefan@datenfreihafen.org>, <matthieu.baerts@tessares.net>,
<netdev@vger.kernel.org>
Cc: <nixiaoming@huawei.com>, <wangle6@huawei.com>, <xiaoqian9@huawei.com>
Subject: [PATCH resend 1/4] nfc: fix refcount leak in llcp_sock_bind()
Date: Thu, 25 Mar 2021 11:51:10 +0800 [thread overview]
Message-ID: <20210325035113.49323-2-nixiaoming@huawei.com> (raw)
In-Reply-To: <20210325035113.49323-1-nixiaoming@huawei.com>
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>
---
net/nfc/llcp_sock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index d257ed3b732a..68832ee4b9f8 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -108,11 +108,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
llcp_sock->service_name_len,
GFP_KERNEL);
if (!llcp_sock->service_name) {
+ nfc_llcp_local_put(llcp_sock->local);
ret = -ENOMEM;
goto put_dev;
}
llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock);
if (llcp_sock->ssap == LLCP_SAP_MAX) {
+ nfc_llcp_local_put(llcp_sock->local);
kfree(llcp_sock->service_name);
llcp_sock->service_name = NULL;
ret = -EADDRINUSE;
--
2.27.0
next prev parent reply other threads:[~2021-03-25 3:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-03 6:16 [PATCH 0/4] nfc: fix Resource leakage and endless loop Xiaoming Ni
2021-03-03 6:16 ` [PATCH 1/4] nfc: fix refcount leak in llcp_sock_bind() Xiaoming Ni
2021-03-03 6:16 ` [PATCH 2/4] nfc: fix refcount leak in llcp_sock_connect() Xiaoming Ni
2021-03-03 6:16 ` [PATCH 3/4] nfc: fix memory " Xiaoming Ni
2021-03-03 6:16 ` [PATCH 4/4] nfc: Avoid endless loops caused by repeated llcp_sock_connect() Xiaoming Ni
2021-03-03 9:28 ` [PATCH 4/4] nfc: Avoid endless loops caused by repeated llcp_sock_connect()(Internet mail) kiyin(尹亮)
2021-03-05 3:24 ` Xiaoming Ni
2021-03-23 13:43 ` [PATCH 0/4] nfc: fix Resource leakage and endless loop Greg KH
2021-03-25 3:51 ` [PATCH resend " Xiaoming Ni
2021-03-25 3:51 ` Xiaoming Ni [this message]
2021-03-25 3:51 ` [PATCH resend 2/4] nfc: fix refcount leak in llcp_sock_connect() Xiaoming Ni
2021-03-25 3:51 ` [PATCH resend 3/4] nfc: fix memory " Xiaoming Ni
2021-03-25 3:51 ` [PATCH resend 4/4] nfc: Avoid endless loops caused by repeated llcp_sock_connect() Xiaoming Ni
2021-03-26 0:30 ` [PATCH resend 0/4] nfc: fix Resource leakage and endless loop patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210325035113.49323-2-nixiaoming@huawei.com \
--to=nixiaoming@huawei.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=kiyin@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=matthieu.baerts@tessares.net \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=sameo@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=stefan@datenfreihafen.org \
--cc=wangle6@huawei.com \
--cc=xiaoqian9@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®