lkml.org 
[lkml]   [2019]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] net: ipv4: Fix a possible null-pointer dereference in inet_csk_rebuild_route()
Date
In inet_csk_rebuild_route(), rt is assigned to NULL on line 1071.
On line 1076, rt is used:
return &rt->dst;
Thus, a possible null-pointer dereference may occur.

To fix this bug, rt is checked before being used.

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

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
net/ipv4/inet_connection_sock.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index f5c163d4771b..27d9d80f3401 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -1073,7 +1073,10 @@ static struct dst_entry *inet_csk_rebuild_route(struct sock *sk, struct flowi *f
sk_setup_caps(sk, &rt->dst);
rcu_read_unlock();

- return &rt->dst;
+ if (rt)
+ return &rt->dst;
+ else
+ return NULL;
}

struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu)
--
2.17.0
\
 
 \ /
  Last update: 2019-07-26 04:26    [W:0.045 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site