* [PATCH net] ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev()
@ 2017-07-28 20:27 Ido Schimmel
2017-07-29 8:48 ` Michał Mirosław
2017-08-01 0:51 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Ido Schimmel @ 2017-07-28 20:27 UTC (permalink / raw)
To: netdev; +Cc: davem, mirq-linux, xiyou.wangcong, Ido Schimmel
Michał reported a NULL pointer deref during fib_sync_down_dev() when
unregistering a netdevice. The problem is that we don't check for
'in_dev' being NULL, which can happen in very specific cases.
Usually routes are flushed upon NETDEV_DOWN sent in either the netdev or
the inetaddr notification chains. However, if an interface isn't
configured with any IP address, then it's possible for host routes to be
flushed following NETDEV_UNREGISTER, after NULLing dev->ip_ptr in
inetdev_destroy().
To reproduce:
$ ip link add type dummy
$ ip route add local 1.1.1.0/24 dev dummy0
$ ip link del dev dummy0
Fix this by checking for the presence of 'in_dev' before referencing it.
Fixes: 982acb97560c ("ipv4: fib: Notify about nexthop status changes")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
Please consider this for -stable.
---
net/ipv4/fib_semantics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 22210010..b8d1817 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1452,7 +1452,7 @@ static int call_fib_nh_notifiers(struct fib_nh *fib_nh,
return call_fib_notifiers(dev_net(fib_nh->nh_dev), event_type,
&info.info);
case FIB_EVENT_NH_DEL:
- if ((IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) &&
+ if ((in_dev && IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) &&
fib_nh->nh_flags & RTNH_F_LINKDOWN) ||
(fib_nh->nh_flags & RTNH_F_DEAD))
return call_fib_notifiers(dev_net(fib_nh->nh_dev),
--
2.9.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev()
2017-07-28 20:27 [PATCH net] ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev() Ido Schimmel
@ 2017-07-29 8:48 ` Michał Mirosław
2017-08-01 0:51 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Michał Mirosław @ 2017-07-29 8:48 UTC (permalink / raw)
To: Ido Schimmel; +Cc: netdev, davem, xiyou.wangcong
On Fri, Jul 28, 2017 at 11:27:44PM +0300, Ido Schimmel wrote:
> Michał reported a NULL pointer deref during fib_sync_down_dev() when
> unregistering a netdevice. The problem is that we don't check for
> 'in_dev' being NULL, which can happen in very specific cases.
>
> Usually routes are flushed upon NETDEV_DOWN sent in either the netdev or
> the inetaddr notification chains. However, if an interface isn't
> configured with any IP address, then it's possible for host routes to be
> flushed following NETDEV_UNREGISTER, after NULLing dev->ip_ptr in
> inetdev_destroy().
>
> To reproduce:
> $ ip link add type dummy
> $ ip route add local 1.1.1.0/24 dev dummy0
> $ ip link del dev dummy0
>
> Fix this by checking for the presence of 'in_dev' before referencing it.
>
> Fixes: 982acb97560c ("ipv4: fib: Notify about nexthop status changes")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev()
2017-07-28 20:27 [PATCH net] ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev() Ido Schimmel
2017-07-29 8:48 ` Michał Mirosław
@ 2017-08-01 0:51 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-08-01 0:51 UTC (permalink / raw)
To: idosch; +Cc: netdev, mirq-linux, xiyou.wangcong
From: Ido Schimmel <idosch@mellanox.com>
Date: Fri, 28 Jul 2017 23:27:44 +0300
> Michał reported a NULL pointer deref during fib_sync_down_dev() when
> unregistering a netdevice. The problem is that we don't check for
> 'in_dev' being NULL, which can happen in very specific cases.
>
> Usually routes are flushed upon NETDEV_DOWN sent in either the netdev or
> the inetaddr notification chains. However, if an interface isn't
> configured with any IP address, then it's possible for host routes to be
> flushed following NETDEV_UNREGISTER, after NULLing dev->ip_ptr in
> inetdev_destroy().
>
> To reproduce:
> $ ip link add type dummy
> $ ip route add local 1.1.1.0/24 dev dummy0
> $ ip link del dev dummy0
>
> Fix this by checking for the presence of 'in_dev' before referencing it.
>
> Fixes: 982acb97560c ("ipv4: fib: Notify about nexthop status changes")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> Please consider this for -stable.
Applied and queued up for -stable, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-01 0:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-28 20:27 [PATCH net] ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev() Ido Schimmel
2017-07-29 8:48 ` Michał Mirosław
2017-08-01 0:51 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).