All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 4349/4685] kernel/bpf/ringbuf.c:166 ringbuf_map_alloc() warn: impossible condition '(attr->max_entries > (((1 << 24) - 2 - ($expr_0x7f1c48643810(30) >> 12)) COPYING CREDITS Documentation Kbuild Kconfig LICENSES MAINTAINERS Makefile README arch block certs crypto drivers fs include init ipc kernel lib mm net samples scripts security sound tools usr virt ((1) << 12))) => (0-u32max > 68719464448)'
@ 2020-07-01 16:39 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-07-01 16:39 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4914 bytes --]

CC: kbuild-all(a)lists.01.org
TO: Andrii Nakryiko <andriin@fb.com>
CC: Daniel Borkmann <daniel@iogearbox.net>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   aab2003999e78bbf2058dae1e661c44ede1d9766
commit: 517bbe1994a3cee29a35c730662277bb5daff582 [4349/4685] bpf: Enforce BPF ringbuf size to be the power of 2
:::::: branch date: 11 hours ago
:::::: commit date: 26 hours ago
config: x86_64-randconfig-m001-20200701 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/bpf/ringbuf.c:166 ringbuf_map_alloc() warn: impossible condition '(attr->max_entries > (((1 << 24) - 2 - ($expr_0x7f1c48643810(30) >> 12)) * ((1) << 12))) => (0-u32max > 68719464448)'

# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=517bbe1994a3cee29a35c730662277bb5daff582
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout 517bbe1994a3cee29a35c730662277bb5daff582
vim +166 kernel/bpf/ringbuf.c

457f44363a8894 Andrii Nakryiko 2020-05-29  149  
457f44363a8894 Andrii Nakryiko 2020-05-29  150  static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr)
457f44363a8894 Andrii Nakryiko 2020-05-29  151  {
457f44363a8894 Andrii Nakryiko 2020-05-29  152  	struct bpf_ringbuf_map *rb_map;
457f44363a8894 Andrii Nakryiko 2020-05-29  153  	u64 cost;
457f44363a8894 Andrii Nakryiko 2020-05-29  154  	int err;
457f44363a8894 Andrii Nakryiko 2020-05-29  155  
457f44363a8894 Andrii Nakryiko 2020-05-29  156  	if (attr->map_flags & ~RINGBUF_CREATE_FLAG_MASK)
457f44363a8894 Andrii Nakryiko 2020-05-29  157  		return ERR_PTR(-EINVAL);
457f44363a8894 Andrii Nakryiko 2020-05-29  158  
457f44363a8894 Andrii Nakryiko 2020-05-29  159  	if (attr->key_size || attr->value_size ||
517bbe1994a3ce Andrii Nakryiko 2020-06-29  160  	    !is_power_of_2(attr->max_entries) ||
517bbe1994a3ce Andrii Nakryiko 2020-06-29  161  	    !PAGE_ALIGNED(attr->max_entries))
457f44363a8894 Andrii Nakryiko 2020-05-29  162  		return ERR_PTR(-EINVAL);
457f44363a8894 Andrii Nakryiko 2020-05-29  163  
517bbe1994a3ce Andrii Nakryiko 2020-06-29  164  #ifdef CONFIG_64BIT
517bbe1994a3ce Andrii Nakryiko 2020-06-29  165  	/* on 32-bit arch, it's impossible to overflow record's hdr->pgoff */
517bbe1994a3ce Andrii Nakryiko 2020-06-29 @166  	if (attr->max_entries > RINGBUF_MAX_DATA_SZ)
517bbe1994a3ce Andrii Nakryiko 2020-06-29  167  		return ERR_PTR(-E2BIG);
517bbe1994a3ce Andrii Nakryiko 2020-06-29  168  #endif
517bbe1994a3ce Andrii Nakryiko 2020-06-29  169  
457f44363a8894 Andrii Nakryiko 2020-05-29  170  	rb_map = kzalloc(sizeof(*rb_map), GFP_USER);
457f44363a8894 Andrii Nakryiko 2020-05-29  171  	if (!rb_map)
457f44363a8894 Andrii Nakryiko 2020-05-29  172  		return ERR_PTR(-ENOMEM);
457f44363a8894 Andrii Nakryiko 2020-05-29  173  
457f44363a8894 Andrii Nakryiko 2020-05-29  174  	bpf_map_init_from_attr(&rb_map->map, attr);
457f44363a8894 Andrii Nakryiko 2020-05-29  175  
457f44363a8894 Andrii Nakryiko 2020-05-29  176  	cost = sizeof(struct bpf_ringbuf_map) +
457f44363a8894 Andrii Nakryiko 2020-05-29  177  	       sizeof(struct bpf_ringbuf) +
457f44363a8894 Andrii Nakryiko 2020-05-29  178  	       attr->max_entries;
457f44363a8894 Andrii Nakryiko 2020-05-29  179  	err = bpf_map_charge_init(&rb_map->map.memory, cost);
457f44363a8894 Andrii Nakryiko 2020-05-29  180  	if (err)
457f44363a8894 Andrii Nakryiko 2020-05-29  181  		goto err_free_map;
457f44363a8894 Andrii Nakryiko 2020-05-29  182  
457f44363a8894 Andrii Nakryiko 2020-05-29  183  	rb_map->rb = bpf_ringbuf_alloc(attr->max_entries, rb_map->map.numa_node);
457f44363a8894 Andrii Nakryiko 2020-05-29  184  	if (IS_ERR(rb_map->rb)) {
457f44363a8894 Andrii Nakryiko 2020-05-29  185  		err = PTR_ERR(rb_map->rb);
457f44363a8894 Andrii Nakryiko 2020-05-29  186  		goto err_uncharge;
457f44363a8894 Andrii Nakryiko 2020-05-29  187  	}
457f44363a8894 Andrii Nakryiko 2020-05-29  188  
457f44363a8894 Andrii Nakryiko 2020-05-29  189  	return &rb_map->map;
457f44363a8894 Andrii Nakryiko 2020-05-29  190  
457f44363a8894 Andrii Nakryiko 2020-05-29  191  err_uncharge:
457f44363a8894 Andrii Nakryiko 2020-05-29  192  	bpf_map_charge_finish(&rb_map->map.memory);
457f44363a8894 Andrii Nakryiko 2020-05-29  193  err_free_map:
457f44363a8894 Andrii Nakryiko 2020-05-29  194  	kfree(rb_map);
457f44363a8894 Andrii Nakryiko 2020-05-29  195  	return ERR_PTR(err);
457f44363a8894 Andrii Nakryiko 2020-05-29  196  }
457f44363a8894 Andrii Nakryiko 2020-05-29  197  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33279 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-01 16:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 16:39 [linux-next:master 4349/4685] kernel/bpf/ringbuf.c:166 ringbuf_map_alloc() warn: impossible condition '(attr->max_entries > (((1 << 24) - 2 - ($expr_0x7f1c48643810(30) >> 12)) COPYING CREDITS Documentation Kbuild Kconfig LICENSES MAINTAINERS Makefile README arch block certs crypto drivers fs include init ipc kernel lib mm net samples scripts security sound tools usr virt ((1) << 12))) => (0-u32max > 68719464448)' kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.