All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyle Zeng <zengyhkyle@gmail.com>
To: davem@davemloft.net
Cc: yoshfuji@linux-ipv6.org, dsahern@kernel.org, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org
Subject: net: ipv6: raw: fixes null pointer deference in rawv6_push_pending_frames
Date: Fri, 6 Jan 2023 14:19:52 -0700	[thread overview]
Message-ID: <Y7iQeGb2xzkf0iR7@westworld> (raw)

The local variable csum_skb is initialized to NULL. It is posible that the skb_queue_walkloop
does not assign csum_skb to a real skb. After the loop, skb will be set to csum_skb, which
means skb is set to NULL. Then when the skb is used later, null pointer deference bug happens.
This patch catches the case and avoids the oops.

Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
---
 net/ipv6/raw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index a06a9f847..982a8b77a 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -556,6 +556,9 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
 		skb = csum_skb;
 	}
 
+	if (skb == NULL)
+		goto out;
+
 	offset += skb_transport_offset(skb);
 	err = skb_copy_bits(skb, offset, &csum, 2);
 	if (err < 0) {
-- 
2.34.1


             reply	other threads:[~2023-01-06 21:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 21:19 Kyle Zeng [this message]
2023-01-06 22:55 ` net: ipv6: raw: fixes null pointer deference in rawv6_push_pending_frames Jakub Kicinski
2023-01-06 23:12   ` Kyle Zeng
2023-01-06 23:57     ` Jakub Kicinski
2023-01-08 22:09       ` Kyle Zeng
2023-01-09  8:45     ` Eric Dumazet
2023-01-09 10:05       ` Herbert Xu
2023-01-09 10:08         ` Eric Dumazet
2023-01-10  0:59           ` [PATCH] ipv6: raw: Deduct extension header length " Herbert Xu
2023-01-11 12:50             ` 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=Y7iQeGb2xzkf0iR7@westworld \
    --to=zengyhkyle@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yoshfuji@linux-ipv6.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.