summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuhammad Usama Anjum <musamaanjum@gmail.com>2021-04-09 03:01:29 +0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-16 11:59:06 +0200
commitff5eb74b7be8cfe152c571d5de3f4bbb81c10c7a (patch)
tree301b074aca9b353d6218ac1cac59a293ea2f8b42
parentaf48f1856d655a3abe9704f9e13532a21dd28ce3 (diff)
downloadlinux-stable-ff5eb74b7be8cfe152c571d5de3f4bbb81c10c7a.tar.gz
linux-stable-ff5eb74b7be8cfe152c571d5de3f4bbb81c10c7a.tar.bz2
linux-stable-ff5eb74b7be8cfe152c571d5de3f4bbb81c10c7a.zip
net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh
commit 864db232dc7036aa2de19749c3d5be0143b24f8f upstream. 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@vger.kernel.org> Addresses-Coverity: ("NULL pointer dereference") Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/ipv6/route.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 03d1a61b4729..70c37951b3f6 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3069,9 +3069,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++;
}