Hi Florent,

I love your patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]

url:    
https://github.com/0day-ci/linux/commits/Florent-Revest/Add-a-snprintf-eBPF-helper/20210412-233921
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: i386-randconfig-s002-20210412 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-280-g2cd6d34e-dirty
        # 
https://github.com/0day-ci/linux/commit/168301dda58989eca274d5f5c926675540010e13
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review 
Florent-Revest/Add-a-snprintf-eBPF-helper/20210412-233921
        git checkout 168301dda58989eca274d5f5c926675540010e13
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>


sparse warnings: (new ones prefixed by >>)
   kernel/bpf/verifier.c:1674:41: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12051:76: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12489:81: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12493:81: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12497:81: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12501:79: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12505:78: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12509:79: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12513:78: sparse: sparse: subtraction of functions? 
Share your drugs
   kernel/bpf/verifier.c:12557:38: sparse: sparse: subtraction of functions? 
Share your drugs
>> kernel/bpf/verifier.c:5944:23: sparse: sparse: non size-preserving integer 
>> to pointer cast

vim +5944 kernel/bpf/verifier.c

  5920  
  5921  static int check_bpf_snprintf_call(struct bpf_verifier_env *env,
  5922                                     struct bpf_reg_state *regs)
  5923  {
  5924          struct bpf_reg_state *fmt_reg = &regs[BPF_REG_3];
  5925          struct bpf_reg_state *data_len_reg = &regs[BPF_REG_5];
  5926          struct bpf_map *fmt_map = fmt_reg->map_ptr;
  5927          int err, fmt_map_off, num_args;
  5928          u64 fmt_addr;
  5929          char *fmt;
  5930  
  5931          /* data must be an array of u64 */
  5932          if (data_len_reg->var_off.value % 8)
  5933                  return -EINVAL;
  5934          num_args = data_len_reg->var_off.value / 8;
  5935  
  5936          /* fmt being ARG_PTR_TO_CONST_STR guarantees that var_off is 
const
  5937           * and map_direct_value_addr is set.
  5938           */
  5939          fmt_map_off = fmt_reg->off + fmt_reg->var_off.value;
  5940          err = fmt_map->ops->map_direct_value_addr(fmt_map, &fmt_addr,
  5941                                                    fmt_map_off);
  5942          if (err)
  5943                  return err;
> 5944          fmt = (char *)fmt_addr + fmt_map_off;
  5945  
  5946          /* We are also guaranteed that fmt+fmt_map_off is NULL 
terminated, we
  5947           * can focus on validating the format specifiers.
  5948           */
  5949          err = bpf_printf_prepare(fmt, UINT_MAX, NULL, NULL, NULL, 
num_args);
  5950          if (err < 0)
  5951                  verbose(env, "Invalid format string\n");
  5952  
  5953          return err;
  5954  }
  5955  

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

Attachment: .config.gz
Description: application/gzip

Reply via email to