lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <201611161759.tCk5fdCO%fengguang.wu@intel.com>
Date:   Wed, 16 Nov 2016 17:10:37 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Nicolas Dichtel <nicolas.dichtel@...nd.com>
Cc:     kbuild-all@...org, avagin@...il.com, davem@...emloft.net,
        netdev@...r.kernel.org, xiyou.wangcong@...il.com,
        Nicolas Dichtel <nicolas.dichtel@...nd.com>
Subject: Re: [PATCH net] net: nsid cannot be allocated for a dead netns

Hi Nicolas,

[auto build test ERROR on net/master]

url:    https://github.com/0day-ci/linux/commits/Nicolas-Dichtel/net-nsid-cannot-be-allocated-for-a-dead-netns/20161116-164739
config: i386-randconfig-x006-201646 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/timer.h:4,
                    from include/linux/workqueue.h:8,
                    from net/core/net_namespace.c:3:
   net/core/net_namespace.c: In function 'alloc_netid':
>> net/core/net_namespace.c:162:49: error: incompatible type for argument 1 of 'atomic_read'
     if (!atomic_read(&net->count) || !&atomic_read(peer->count))
                                                    ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> net/core/net_namespace.c:162:2: note: in expansion of macro 'if'
     if (!atomic_read(&net->count) || !&atomic_read(peer->count))
     ^~
   In file included from arch/x86/include/asm/msr.h:66:0,
                    from arch/x86/include/asm/processor.h:20,
                    from arch/x86/include/asm/cpufeature.h:4,
                    from arch/x86/include/asm/thread_info.h:52,
                    from include/linux/thread_info.h:58,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:59,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:5,
                    from include/linux/workqueue.h:8,
                    from net/core/net_namespace.c:3:
   arch/x86/include/asm/atomic.h:24:28: note: expected 'const atomic_t * {aka const struct <anonymous> *}' but argument is of type 'atomic_t {aka struct <anonymous>}'
    static __always_inline int atomic_read(const atomic_t *v)
                               ^~~~~~~~~~~
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/timer.h:4,
                    from include/linux/workqueue.h:8,
                    from net/core/net_namespace.c:3:
>> net/core/net_namespace.c:162:49: error: incompatible type for argument 1 of 'atomic_read'
     if (!atomic_read(&net->count) || !&atomic_read(peer->count))
                                                    ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> net/core/net_namespace.c:162:2: note: in expansion of macro 'if'
     if (!atomic_read(&net->count) || !&atomic_read(peer->count))
     ^~
   In file included from arch/x86/include/asm/msr.h:66:0,
                    from arch/x86/include/asm/processor.h:20,
                    from arch/x86/include/asm/cpufeature.h:4,
                    from arch/x86/include/asm/thread_info.h:52,
                    from include/linux/thread_info.h:58,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:59,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:5,
                    from include/linux/workqueue.h:8,
                    from net/core/net_namespace.c:3:
   arch/x86/include/asm/atomic.h:24:28: note: expected 'const atomic_t * {aka const struct <anonymous> *}' but argument is of type 'atomic_t {aka struct <anonymous>}'
    static __always_inline int atomic_read(const atomic_t *v)
                               ^~~~~~~~~~~
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/timer.h:4,
                    from include/linux/workqueue.h:8,
                    from net/core/net_namespace.c:3:
>> net/core/net_namespace.c:162:49: error: incompatible type for argument 1 of 'atomic_read'
     if (!atomic_read(&net->count) || !&atomic_read(peer->count))
                                                    ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> net/core/net_namespace.c:162:2: note: in expansion of macro 'if'
     if (!atomic_read(&net->count) || !&atomic_read(peer->count))
     ^~
   In file included from arch/x86/include/asm/msr.h:66:0,
                    from arch/x86/include/asm/processor.h:20,
                    from arch/x86/include/asm/cpufeature.h:4,
                    from arch/x86/include/asm/thread_info.h:52,
                    from include/linux/thread_info.h:58,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:59,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:5,
                    from include/linux/workqueue.h:8,
                    from net/core/net_namespace.c:3:
   arch/x86/include/asm/atomic.h:24:28: note: expected 'const atomic_t * {aka const struct <anonymous> *}' but argument is of type 'atomic_t {aka struct <anonymous>}'
    static __always_inline int atomic_read(const atomic_t *v)
                               ^~~~~~~~~~~

vim +/atomic_read +162 net/core/net_namespace.c

     1	#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
     2	
   > 3	#include <linux/workqueue.h>
     4	#include <linux/rtnetlink.h>
     5	#include <linux/cache.h>
     6	#include <linux/slab.h>
     7	#include <linux/list.h>
     8	#include <linux/delay.h>
     9	#include <linux/sched.h>
    10	#include <linux/idr.h>
    11	#include <linux/rculist.h>
    12	#include <linux/nsproxy.h>
    13	#include <linux/fs.h>
    14	#include <linux/proc_ns.h>
    15	#include <linux/file.h>
    16	#include <linux/export.h>
    17	#include <linux/user_namespace.h>
    18	#include <linux/net_namespace.h>
    19	#include <net/sock.h>
    20	#include <net/netlink.h>
    21	#include <net/net_namespace.h>
    22	#include <net/netns/generic.h>
    23	
    24	/*
    25	 *	Our network namespace constructor/destructor lists
    26	 */
    27	
    28	static LIST_HEAD(pernet_list);
    29	static struct list_head *first_device = &pernet_list;
    30	DEFINE_MUTEX(net_mutex);
    31	
    32	LIST_HEAD(net_namespace_list);
    33	EXPORT_SYMBOL_GPL(net_namespace_list);
    34	
    35	struct net init_net = {
    36		.dev_base_head = LIST_HEAD_INIT(init_net.dev_base_head),
    37	};
    38	EXPORT_SYMBOL(init_net);
    39	
    40	static bool init_net_initialized;
    41	
    42	#define INITIAL_NET_GEN_PTRS	13 /* +1 for len +2 for rcu_head */
    43	
    44	static unsigned int max_gen_ptrs = INITIAL_NET_GEN_PTRS;
    45	
    46	static struct net_generic *net_alloc_generic(void)
    47	{
    48		struct net_generic *ng;
    49		size_t generic_size = offsetof(struct net_generic, ptr[max_gen_ptrs]);
    50	
    51		ng = kzalloc(generic_size, GFP_KERNEL);
    52		if (ng)
    53			ng->len = max_gen_ptrs;
    54	
    55		return ng;
    56	}
    57	
    58	static int net_assign_generic(struct net *net, int id, void *data)
    59	{
    60		struct net_generic *ng, *old_ng;
    61	
    62		BUG_ON(!mutex_is_locked(&net_mutex));
    63		BUG_ON(id == 0);
    64	
    65		old_ng = rcu_dereference_protected(net->gen,
    66						   lockdep_is_held(&net_mutex));
    67		ng = old_ng;
    68		if (old_ng->len >= id)
    69			goto assign;
    70	
    71		ng = net_alloc_generic();
    72		if (ng == NULL)
    73			return -ENOMEM;
    74	
    75		/*
    76		 * Some synchronisation notes:
    77		 *
    78		 * The net_generic explores the net->gen array inside rcu
    79		 * read section. Besides once set the net->gen->ptr[x]
    80		 * pointer never changes (see rules in netns/generic.h).
    81		 *
    82		 * That said, we simply duplicate this array and schedule
    83		 * the old copy for kfree after a grace period.
    84		 */
    85	
    86		memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*));
    87	
    88		rcu_assign_pointer(net->gen, ng);
    89		kfree_rcu(old_ng, rcu);
    90	assign:
    91		ng->ptr[id - 1] = data;
    92		return 0;
    93	}
    94	
    95	static int ops_init(const struct pernet_operations *ops, struct net *net)
    96	{
    97		int err = -ENOMEM;
    98		void *data = NULL;
    99	
   100		if (ops->id && ops->size) {
   101			data = kzalloc(ops->size, GFP_KERNEL);
   102			if (!data)
   103				goto out;
   104	
   105			err = net_assign_generic(net, *ops->id, data);
   106			if (err)
   107				goto cleanup;
   108		}
   109		err = 0;
   110		if (ops->init)
   111			err = ops->init(net);
   112		if (!err)
   113			return 0;
   114	
   115	cleanup:
   116		kfree(data);
   117	
   118	out:
   119		return err;
   120	}
   121	
   122	static void ops_free(const struct pernet_operations *ops, struct net *net)
   123	{
   124		if (ops->id && ops->size) {
   125			int id = *ops->id;
   126			kfree(net_generic(net, id));
   127		}
   128	}
   129	
   130	static void ops_exit_list(const struct pernet_operations *ops,
   131				  struct list_head *net_exit_list)
   132	{
   133		struct net *net;
   134		if (ops->exit) {
   135			list_for_each_entry(net, net_exit_list, exit_list)
   136				ops->exit(net);
   137		}
   138		if (ops->exit_batch)
   139			ops->exit_batch(net_exit_list);
   140	}
   141	
   142	static void ops_free_list(const struct pernet_operations *ops,
   143				  struct list_head *net_exit_list)
   144	{
   145		struct net *net;
   146		if (ops->size && ops->id) {
   147			list_for_each_entry(net, net_exit_list, exit_list)
   148				ops_free(ops, net);
   149		}
   150	}
   151	
   152	/* should be called with nsid_lock held */
   153	static int alloc_netid(struct net *net, struct net *peer, int reqid)
   154	{
   155		int min = 0, max = 0;
   156	
   157		if (reqid >= 0) {
   158			min = reqid;
   159			max = reqid + 1;
   160		}
   161	
 > 162		if (!atomic_read(&net->count) || !&atomic_read(peer->count))
   163			return -EINVAL;
   164	
   165		return idr_alloc(&net->netns_ids, peer, min, max, GFP_ATOMIC);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (27870 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ