Re: [Devel] [PATCH 1/2] netns: fix NULL-dereference in dev_net()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 14, 2008 at 03:27:25PM -0400, Brian Haley wrote:
> Change dev_net() to handle a NULL argument - return &init_net instead.

> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -781,10 +781,10 @@ static inline
>  struct net *dev_net(const struct net_device *dev)
>  {
>  #ifdef CONFIG_NET_NS
> -	return dev->nd_net;
> -#else
> -	return &init_net;
> +	if (dev)
> +		return dev->nd_net;
>  #endif
> +	return &init_net;
>  }

This is ugly and wrong.

The only assymetry between init_net and dynamically created netns is
that some data structures are created only when init_net is initialized
like some kmem caches and so on.

And some sysctls that some people may ban in netns.

Modulo that, init_net is no different from the rest.

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux