From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
syzbot+9fe8e3f6c64aa5e5d82c@syzkaller.appspotmail.com
Subject: [Patch net] netrom: fix a potential NULL pointer dereference
Date: Sat, 30 Nov 2019 12:05:40 -0800 [thread overview]
Message-ID: <20191130200540.2461-1-xiyou.wangcong@gmail.com> (raw)
It is possible that the skb gets removed between skb_peek() and
skb_dequeue(). So we should just check the return value of
skb_dequeue(). Otherwise, skb_clone() may get a NULL pointer.
Technically, this should be protected by sock lock, but netrom
doesn't use it correctly. It is harder to fix sock lock than just
fixing this.
Reported-by: syzbot+9fe8e3f6c64aa5e5d82c@syzkaller.appspotmail.com
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/netrom/nr_out.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c
index 44929657f5b7..9491a0c02bce 100644
--- a/net/netrom/nr_out.c
+++ b/net/netrom/nr_out.c
@@ -131,9 +131,6 @@ void nr_kick(struct sock *sk)
if (nr->condition & NR_COND_PEER_RX_BUSY)
return;
- if (!skb_peek(&sk->sk_write_queue))
- return;
-
start = (skb_peek(&nr->ack_queue) == NULL) ? nr->va : nr->vs;
end = (nr->va + nr->window) % NR_MODULUS;
@@ -151,6 +148,8 @@ void nr_kick(struct sock *sk)
* Dequeue the frame and copy it.
*/
skb = skb_dequeue(&sk->sk_write_queue);
+ if (!skb)
+ return;
do {
if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {
--
2.21.0
next reply other threads:[~2019-11-30 20:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-30 20:05 Cong Wang [this message]
2019-11-30 20:31 ` [Patch net] netrom: fix a potential NULL pointer dereference David Miller
2019-11-30 20:42 ` Cong Wang
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=20191130200540.2461-1-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=syzbot+9fe8e3f6c64aa5e5d82c@syzkaller.appspotmail.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).