Netdev List
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ipv6: Fix a possible null-pointer dereference in ip6_xmit()
@ 2019-07-26  8:03 Jia-Ju Bai
  2019-07-26 11:44 ` Willem de Bruijn
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2019-07-26  8:03 UTC (permalink / raw)
  To: davem, kuznet, yoshfuji; +Cc: netdev, linux-kernel, Jia-Ju Bai

In ip6_xmit(), there is an if statement on line 245 to check whether 
np is NULL:
    if (np)

When np is NULL, it is used on line 251:
    ip6_autoflowlabel(net, np)
        if (!np->autoflowlabel_set)

Thus, a possible null-pointer dereference may occur.

To fix this bug, np is checked before calling 
ip6_autoflowlabel(net,np).

This bug is found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 net/ipv6/ip6_output.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 8e49fd62eea9..07db5ab6e970 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -247,8 +247,10 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
 	if (hlimit < 0)
 		hlimit = ip6_dst_hoplimit(dst);
 
-	ip6_flow_hdr(hdr, tclass, ip6_make_flowlabel(net, skb, fl6->flowlabel,
-				ip6_autoflowlabel(net, np), fl6));
+	if (np) {
+		ip6_flow_hdr(hdr, tclass, ip6_make_flowlabel(net, skb, fl6->flowlabel,
+					ip6_autoflowlabel(net, np), fl6));
+	}
 
 	hdr->payload_len = htons(seg_len);
 	hdr->nexthdr = proto;
-- 
2.17.0


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

end of thread, other threads:[~2019-07-26 11:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-26  8:03 [PATCH 1/2] net: ipv6: Fix a possible null-pointer dereference in ip6_xmit() Jia-Ju Bai
2019-07-26 11:44 ` Willem de Bruijn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox