[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210408220129.GA3111136@LEGION>
Date: Fri, 9 Apr 2021 03:01:29 +0500
From: Muhammad Usama Anjum <musamaanjum@...il.com>
To: "David S. Miller" <davem@...emloft.net>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Jakub Kicinski <kuba@...nel.org>,
"open list:NETWORKING [IPv4/IPv6]" <netdev@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Cc: musamaanjum@...il.com, kernel-janitors@...r.kernel.org,
colin.king@...onical.com, dan.carpenter@...cle.com,
stable@...r.kernel.org
Subject: [PATCH] net: ipv6: check for validity before dereferencing
cfg->fc_nlinfo.nlh
nlh is being checked for validtity two times when it is dereferenced in
this function. Check for validity again when updating the flags through
nlh pointer to make the dereferencing safe.
CC: <stable@...r.kernel.org>
Addresses-Coverity: ("NULL pointer dereference")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@...il.com>
---
net/ipv6/route.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 28801ae80548..a22822bdbf39 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5206,9 +5206,11 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
* nexthops have been replaced by first new, the rest should
* be added to it.
*/
- cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
- NLM_F_REPLACE);
- cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
+ if (cfg->fc_nlinfo.nlh) {
+ cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
+ NLM_F_REPLACE);
+ cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
+ }
nhn++;
}
--
2.25.1
Powered by blists - more mailing lists