All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] net/ipv6/addrconf.c: Check the return value of __in6_dev_get() in addrconf_type_change()
@ 2022-08-20 10:24 lily
  2022-08-21 18:19 ` Cong Wang
  0 siblings, 1 reply; 2+ messages in thread
From: lily @ 2022-08-20 10:24 UTC (permalink / raw)
  To: ziw002, lizhong, netdev, linux-kernel
  Cc: lily, davem, yoshfuji, dsahern, edumazet, kuba, pabeni

The function __in6_dev_get() could return NULL pointer. This needs to be
checked before used in ipv6_mc_remap() and ipv6_mc_unmap(). Otherwise it
could result in null pointer dereference.
---
 net/ipv6/addrconf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b624e3d8c5f0..b5e490fe0bcd 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3718,6 +3718,9 @@ static void addrconf_type_change(struct net_device *dev, unsigned long event)
 
 	idev = __in6_dev_get(dev);
 
+	if(!idev)
+		return;
+	
 	if (event == NETDEV_POST_TYPE_CHANGE)
 		ipv6_mc_remap(idev);
 	else if (event == NETDEV_PRE_TYPE_CHANGE)
-- 
2.25.1


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

* Re: [PATCH v1] net/ipv6/addrconf.c: Check the return value of __in6_dev_get() in addrconf_type_change()
  2022-08-20 10:24 [PATCH v1] net/ipv6/addrconf.c: Check the return value of __in6_dev_get() in addrconf_type_change() lily
@ 2022-08-21 18:19 ` Cong Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Cong Wang @ 2022-08-21 18:19 UTC (permalink / raw)
  To: lily
  Cc: ziw002, lizhong, netdev, linux-kernel, davem, yoshfuji, dsahern,
	edumazet, kuba, pabeni

On Sat, Aug 20, 2022 at 03:24:34AM -0700, lily wrote:
> The function __in6_dev_get() could return NULL pointer. This needs to be
> checked before used in ipv6_mc_remap() and ipv6_mc_unmap(). Otherwise it
> could result in null pointer dereference.

Its caller already checks it:

3689                 if (idev)
3690                         addrconf_type_change(dev, event);
3691                 break;



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

end of thread, other threads:[~2022-08-21 18:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20 10:24 [PATCH v1] net/ipv6/addrconf.c: Check the return value of __in6_dev_get() in addrconf_type_change() lily
2022-08-21 18:19 ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.