net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh
Subsystems (5)
PATCH 1/1 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: <[email protected]>
Addresses-Coverity: ("NULL pointer dereference")
--- net/ipv6/route.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/ipv6/route.c +5 -3
@@ -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++; }
Signature · 1 line
2.25.1
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 9 lines · On Fri, 9 Apr 2021 03:01:29 +0500 you wrote:
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: <[email protected]>
Addresses-Coverity: ("NULL pointer dereference")Signed-off-by Muhammad Usama Anjum <[email protected]>[...]
Here is the summary with links:
- net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh
https://git.kernel.org/netdev/net/c/864db232dc70
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html