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>] [day] [month] [year] [list]
Message-ID: <202309101935.zgcMq85L-lkp@intel.com>
Date:   Sun, 10 Sep 2023 20:02:23 +0800
From:   kernel test robot <lkp@...el.com>
To:     Alexei Starovoitov <ast@...nel.org>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Daniel Borkmann <daniel@...earbox.net>
Subject: kernel/bpf/hashtab.c:1059:30: sparse: sparse: incorrect type in
 assignment (different address spaces)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   535a265d7f0dd50d8c3a4f8b4f3a452d56bd160f
commit: ee4ed53c5eb62f49f23560cc2642353547e46c32 bpf: Convert percpu hash map to per-cpu bpf_mem_alloc.
date:   1 year ago
config: i386-randconfig-063-20230910 (https://download.01.org/0day-ci/archive/20230910/202309101935.zgcMq85L-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230910/202309101935.zgcMq85L-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309101935.zgcMq85L-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> kernel/bpf/hashtab.c:1059:30: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void [noderef] __percpu *[assigned] pptr @@     got void * @@
   kernel/bpf/hashtab.c:1059:30: sparse:     expected void [noderef] __percpu *[assigned] pptr
   kernel/bpf/hashtab.c:1059:30: sparse:     got void *
>> kernel/bpf/hashtab.c:1065:44: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *ptr_to_pptr @@     got void [noderef] __percpu *[assigned] pptr @@
   kernel/bpf/hashtab.c:1065:44: sparse:     expected void *ptr_to_pptr
   kernel/bpf/hashtab.c:1065:44: sparse:     got void [noderef] __percpu *[assigned] pptr
>> kernel/bpf/hashtab.c:1066:34: sparse: sparse: cast removes address space '__percpu' of expression
   kernel/bpf/hashtab.c:1066:30: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void [noderef] __percpu *[assigned] pptr @@     got void * @@
   kernel/bpf/hashtab.c:1066:30: sparse:     expected void [noderef] __percpu *[assigned] pptr
   kernel/bpf/hashtab.c:1066:30: sparse:     got void *
   kernel/bpf/hashtab.c:1441:27: sparse: sparse: context imbalance in 'htab_map_delete_elem' - unexpected unlock
   kernel/bpf/hashtab.c:1475:27: sparse: sparse: context imbalance in 'htab_lru_map_delete_elem' - unexpected unlock
   kernel/bpf/hashtab.c:1650:27: sparse: sparse: context imbalance in '__htab_map_lookup_and_delete_elem' - unexpected unlock
   kernel/bpf/hashtab.c: note: in included file (through include/linux/workqueue.h, include/linux/bpf.h):
   include/linux/rcupdate.h:737:9: sparse: sparse: context imbalance in '__htab_map_lookup_and_delete_batch' - unexpected unlock
   include/linux/rcupdate.h:737:9: sparse: sparse: context imbalance in 'bpf_hash_map_seq_find_next' - unexpected unlock
   include/linux/rcupdate.h:737:9: sparse: sparse: context imbalance in 'bpf_hash_map_seq_stop' - unexpected unlock

vim +1059 kernel/bpf/hashtab.c

  1006	
  1007	static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
  1008						 void *value, u32 key_size, u32 hash,
  1009						 bool percpu, bool onallcpus,
  1010						 struct htab_elem *old_elem)
  1011	{
  1012		u32 size = htab->map.value_size;
  1013		bool prealloc = htab_is_prealloc(htab);
  1014		struct htab_elem *l_new, **pl_new;
  1015		void __percpu *pptr;
  1016	
  1017		if (prealloc) {
  1018			if (old_elem) {
  1019				/* if we're updating the existing element,
  1020				 * use per-cpu extra elems to avoid freelist_pop/push
  1021				 */
  1022				pl_new = this_cpu_ptr(htab->extra_elems);
  1023				l_new = *pl_new;
  1024				htab_put_fd_value(htab, old_elem);
  1025				*pl_new = old_elem;
  1026			} else {
  1027				struct pcpu_freelist_node *l;
  1028	
  1029				l = __pcpu_freelist_pop(&htab->freelist);
  1030				if (!l)
  1031					return ERR_PTR(-E2BIG);
  1032				l_new = container_of(l, struct htab_elem, fnode);
  1033			}
  1034		} else {
  1035			if (is_map_full(htab))
  1036				if (!old_elem)
  1037					/* when map is full and update() is replacing
  1038					 * old element, it's ok to allocate, since
  1039					 * old element will be freed immediately.
  1040					 * Otherwise return an error
  1041					 */
  1042					return ERR_PTR(-E2BIG);
  1043			inc_elem_count(htab);
  1044			l_new = bpf_mem_cache_alloc(&htab->ma);
  1045			if (!l_new) {
  1046				l_new = ERR_PTR(-ENOMEM);
  1047				goto dec_count;
  1048			}
  1049			check_and_init_map_value(&htab->map,
  1050						 l_new->key + round_up(key_size, 8));
  1051		}
  1052	
  1053		memcpy(l_new->key, key, key_size);
  1054		if (percpu) {
  1055			if (prealloc) {
  1056				pptr = htab_elem_get_ptr(l_new, key_size);
  1057			} else {
  1058				/* alloc_percpu zero-fills */
> 1059				pptr = bpf_mem_cache_alloc(&htab->pcpu_ma);
  1060				if (!pptr) {
  1061					bpf_mem_cache_free(&htab->ma, l_new);
  1062					l_new = ERR_PTR(-ENOMEM);
  1063					goto dec_count;
  1064				}
> 1065				l_new->ptr_to_pptr = pptr;
> 1066				pptr = *(void **)pptr;
  1067			}
  1068	
  1069			pcpu_init_value(htab, pptr, value, onallcpus);
  1070	
  1071			if (!prealloc)
  1072				htab_elem_set_ptr(l_new, key_size, pptr);
  1073		} else if (fd_htab_map_needs_adjust(htab)) {
  1074			size = round_up(size, 8);
  1075			memcpy(l_new->key + round_up(key_size, 8), value, size);
  1076		} else {
  1077			copy_map_value(&htab->map,
  1078				       l_new->key + round_up(key_size, 8),
  1079				       value);
  1080		}
  1081	
  1082		l_new->hash = hash;
  1083		return l_new;
  1084	dec_count:
  1085		dec_elem_count(htab);
  1086		return l_new;
  1087	}
  1088	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ