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 3/4] nfc: fix memory leak in llcp_sock_connect()
Date: Thu, 25 Mar 2021 11:51:12 +0800 [thread overview]
Message-ID: <20210325035113.49323-4-nixiaoming@huawei.com> (raw)
In-Reply-To: <20210325035113.49323-1-nixiaoming@huawei.com>
In llcp_sock_connect(), use kmemdup to allocate memory for
"llcp_sock->service_name". The memory is not released in the sock_unlink
label of the subsequent failure branch.
As a result, memory leakage occurs.
fix CVE-2020-25672
Fixes: d646960f7986 ("NFC: Initial LLCP support")
Reported-by: "kiyin(尹亮)" <kiyin@tencent.com>
Link: https://www.openwall.com/lists/oss-security/2020/11/01/1
Cc: <stable@vger.kernel.org> #v3.3
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 9e2799ee1595..59172614b249 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -746,6 +746,8 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
sock_unlink:
nfc_llcp_sock_unlink(&local->connecting_sockets, sk);
+ kfree(llcp_sock->service_name);
+ llcp_sock->service_name = NULL;
sock_llcp_release:
nfc_llcp_put_ssap(local, llcp_sock->ssap);
--
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 ` [PATCH resend 1/4] nfc: fix refcount leak in llcp_sock_bind() Xiaoming Ni
2021-03-25 3:51 ` [PATCH resend 2/4] nfc: fix refcount leak in llcp_sock_connect() Xiaoming Ni
2021-03-25 3:51 ` Xiaoming Ni [this message]
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-4-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;
as well as URLs for NNTP newsgroup(s).