From: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
To: dhowells@redhat.com, davem@davemloft.net, kuba@kernel.org
Cc: linux-afs@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Subject: [PATCH] net/rxrpc: Fix a use after free in rxrpc_input_packet
Date: Thu, 1 Apr 2021 02:35:45 -0700 [thread overview]
Message-ID: <20210401093545.4055-1-lyl2019@mail.ustc.edu.cn> (raw)
In the case RXRPC_PACKET_TYPE_DATA of rxrpc_input_packet, if
skb_unshare(skb,..) failed, it will free the skb and return NULL.
But if skb_unshare() return NULL, the freed skb will be used by
rxrpc_eaten_skb(skb,..).
I see that rxrpc_eaten_skb() is used to drop a ref of skb. As the skb
is already freed in skb_unshare() on error, my patch removes the
rxrpc_eaten_skb() to avoid the uaf.
Fixes: d0d5c0cd1e711 ("rxrpc: Use skb_unshare() rather than skb_cow_data()")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
net/rxrpc/input.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index dc201363f2c4..9ba408064465 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -1281,10 +1281,8 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
*/
if (sp->hdr.securityIndex != 0) {
struct sk_buff *nskb = skb_unshare(skb, GFP_ATOMIC);
- if (!nskb) {
- rxrpc_eaten_skb(skb, rxrpc_skb_unshared_nomem);
+ if (!nskb)
goto out;
- }
if (nskb != skb) {
rxrpc_eaten_skb(skb, rxrpc_skb_received);
--
2.25.1
next reply other threads:[~2021-04-01 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 9:35 Lv Yunlong [this message]
2021-04-01 12:54 ` David Howells
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=20210401093545.4055-1-lyl2019@mail.ustc.edu.cn \
--to=lyl2019@mail.ustc.edu.cn \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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®