diff mbox series

[net] net: sit: unregister_netdevice on newlink's error path

Message ID 20210114012947.2515313-1-kuba@kernel.org (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net] net: sit: unregister_netdevice on newlink's error path | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 2 maintainers not CCed: yoshfuji@linux-ipv6.org kuznet@ms2.inr.ac.ru
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Jakub Kicinski Jan. 14, 2021, 1:29 a.m. UTC
We need to unregister the netdevice if config failed.
.ndo_uninit takes care of most of the heavy lifting.

This was uncovered by recent commit c269a24ce057 ("net: make
free_netdev() more lenient with unregistering devices").
Previously the partially-initialized device would be left
in the system.

Reported-and-tested-by: syzbot+2393580080a2da190f04@syzkaller.appspotmail.com
Fixes: e2f1f072db8d ("sit: allow to configure 6rd tunnels via netlink")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ipv6/sit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Nicolas Dichtel Jan. 14, 2021, 8:49 a.m. UTC | #1
Le 14/01/2021 à 02:29, Jakub Kicinski a écrit :
[snip]
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -1645,8 +1645,11 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
>  	}
>  
>  #ifdef CONFIG_IPV6_SIT_6RD
> -	if (ipip6_netlink_6rd_parms(data, &ip6rd))
> +	if (ipip6_netlink_6rd_parms(data, &ip6rd)) {
>  		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
> +		if (err)
nit: I would prefer 'if (err < 0)' to be consistent with the rest of the sit
code, but it's purely aesthetic (ipip6_tunnel_update_6rd() returns a negative
value or 0).

With or without this:
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

> +			unregister_netdevice_queue(dev, NULL);
> +	}
>  #endif
>  
>  	return err;
>
Jakub Kicinski Jan. 14, 2021, 6:27 p.m. UTC | #2
On Thu, 14 Jan 2021 09:49:48 +0100 Nicolas Dichtel wrote:
> Le 14/01/2021 à 02:29, Jakub Kicinski a écrit :
> [snip]
> > --- a/net/ipv6/sit.c
> > +++ b/net/ipv6/sit.c
> > @@ -1645,8 +1645,11 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
> >  	}
> >  
> >  #ifdef CONFIG_IPV6_SIT_6RD
> > -	if (ipip6_netlink_6rd_parms(data, &ip6rd))
> > +	if (ipip6_netlink_6rd_parms(data, &ip6rd)) {
> >  		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
> > +		if (err)  
> nit: I would prefer 'if (err < 0)' to be consistent with the rest of the sit
> code, but it's purely aesthetic (ipip6_tunnel_update_6rd() returns a negative
> value or 0).

Done.

> With or without this:
> Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Thanks for the review, applied!
diff mbox series

Patch

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 2da0ee703779..440175bc2e89 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1645,8 +1645,11 @@  static int ipip6_newlink(struct net *src_net, struct net_device *dev,
 	}
 
 #ifdef CONFIG_IPV6_SIT_6RD
-	if (ipip6_netlink_6rd_parms(data, &ip6rd))
+	if (ipip6_netlink_6rd_parms(data, &ip6rd)) {
 		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
+		if (err)
+			unregister_netdevice_queue(dev, NULL);
+	}
 #endif
 
 	return err;