netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net: ipv6: raw: fixes null pointer deference in rawv6_push_pending_frames
@ 2023-01-06 21:19 Kyle Zeng
  2023-01-06 22:55 ` Jakub Kicinski
  0 siblings, 1 reply; 10+ messages in thread
From: Kyle Zeng @ 2023-01-06 21:19 UTC (permalink / raw)
  To: davem; +Cc: yoshfuji, dsahern, edumazet, kuba, pabeni, netdev

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-11 12:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 21:19 net: ipv6: raw: fixes null pointer deference in rawv6_push_pending_frames Kyle Zeng
2023-01-06 22:55 ` 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

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).