Hi Alexei,

I love your patch! Perhaps something to improve:

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

url:    
https://github.com/0day-ci/linux/commits/Alexei-Starovoitov/bpf-Pointers-beyond-packet-end/20201022-022139
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: i386-randconfig-r026-20201021 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # 
https://github.com/0day-ci/linux/commit/1aa4c81ae1dbbc3b6de7416f0384cde6cc8739b1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review 
Alexei-Starovoitov/bpf-Pointers-beyond-packet-end/20201022-022139
        git checkout 1aa4c81ae1dbbc3b6de7416f0384cde6cc8739b1
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

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

All warnings (new ones prefixed by >>):

   kernel/bpf/verifier.c: In function 'is_pkt_ptr_branch_taken':
>> kernel/bpf/verifier.c:7029:24: warning: variable 'pkt_end' set but not used 
>> [-Wunused-but-set-variable]
    7029 |  struct bpf_reg_state *pkt_end, *pkt;
         |                        ^~~~~~~
   In file included from include/linux/bpf_verifier.h:8,
                    from kernel/bpf/verifier.c:12:
   kernel/bpf/verifier.c: In function 'jit_subprogs':
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'unsigned int (*)(const void *, const struct bpf_insn *)' to 'u64 
(*)(u64,  u64,  u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long 
unsigned int,  long long unsigned int,  long long unsigned int,  long long 
unsigned int,  long long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:10793:16: note: in expansion of macro 'BPF_CAST_CALL'
   10793 |    insn->imm = BPF_CAST_CALL(func[subprog]->bpf_func) -
         |                ^~~~~~~~~~~~~
   kernel/bpf/verifier.c: In function 'fixup_bpf_calls':
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'void * (* const)(struct bpf_map *, void *)' to 'u64 (*)(u64,  u64,  
u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long unsigned int,  
long long unsigned int,  long long unsigned int,  long long unsigned int,  long 
long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:11186:17: note: in expansion of macro 'BPF_CAST_CALL'
   11186 |     insn->imm = BPF_CAST_CALL(ops->map_lookup_elem) -
         |                 ^~~~~~~~~~~~~
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'int (* const)(struct bpf_map *, void *, void *, u64)' {aka 'int (* 
const)(struct bpf_map *, void *, void *, long long unsigned int)'} to 'u64 
(*)(u64,  u64,  u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long 
unsigned int,  long long unsigned int,  long long unsigned int,  long long 
unsigned int,  long long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:11190:17: note: in expansion of macro 'BPF_CAST_CALL'
   11190 |     insn->imm = BPF_CAST_CALL(ops->map_update_elem) -
         |                 ^~~~~~~~~~~~~
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'int (* const)(struct bpf_map *, void *)' to 'u64 (*)(u64,  u64,  
u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long unsigned int,  
long long unsigned int,  long long unsigned int,  long long unsigned int,  long 
long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:11194:17: note: in expansion of macro 'BPF_CAST_CALL'
   11194 |     insn->imm = BPF_CAST_CALL(ops->map_delete_elem) -
         |                 ^~~~~~~~~~~~~
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'int (* const)(struct bpf_map *, void *, u64)' {aka 'int (* 
const)(struct bpf_map *, void *, long long unsigned int)'} to 'u64 (*)(u64,  
u64,  u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long unsigned 
int,  long long unsigned int,  long long unsigned int,  long long unsigned int, 
 long long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:11198:17: note: in expansion of macro 'BPF_CAST_CALL'
   11198 |     insn->imm = BPF_CAST_CALL(ops->map_push_elem) -
         |                 ^~~~~~~~~~~~~
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'int (* const)(struct bpf_map *, void *)' to 'u64 (*)(u64,  u64,  
u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long unsigned int,  
long long unsigned int,  long long unsigned int,  long long unsigned int,  long 
long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:11202:17: note: in expansion of macro 'BPF_CAST_CALL'
   11202 |     insn->imm = BPF_CAST_CALL(ops->map_pop_elem) -
         |                 ^~~~~~~~~~~~~
   include/linux/filter.h:345:4: warning: cast between incompatible function 
types from 'int (* const)(struct bpf_map *, void *)' to 'u64 (*)(u64,  u64,  
u64,  u64,  u64)' {aka 'long long unsigned int (*)(long long unsigned int,  
long long unsigned int,  long long unsigned int,  long long unsigned int,  long 
long unsigned int)'} [-Wcast-function-type]
     345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
         |    ^
   kernel/bpf/verifier.c:11206:17: note: in expansion of macro 'BPF_CAST_CALL'
   11206 |     insn->imm = BPF_CAST_CALL(ops->map_peek_elem) -
         |                 ^~~~~~~~~~~~~

vim +/pkt_end +7029 kernel/bpf/verifier.c

  7024  
  7025  static int is_pkt_ptr_branch_taken(struct bpf_reg_state *dst_reg,
  7026                                     struct bpf_reg_state *src_reg,
  7027                                     u8 opcode)
  7028  {
> 7029          struct bpf_reg_state *pkt_end, *pkt;
  7030  
  7031          if (src_reg->type == PTR_TO_PACKET_END) {
  7032                  pkt_end = src_reg;
  7033                  pkt = dst_reg;
  7034          } else if (dst_reg->type == PTR_TO_PACKET_END) {
  7035                  pkt_end = dst_reg;
  7036                  pkt = src_reg;
  7037                  opcode = flip_opcode(opcode);
  7038          } else {
  7039                  return -1;
  7040          }
  7041  
  7042          if (pkt->range >= 0)
  7043                  return -1;
  7044  
  7045          switch (opcode) {
  7046          case BPF_JLE:
  7047                  /* pkt <= pkt_end */
  7048                  fallthrough;
  7049          case BPF_JGT:
  7050                  /* pkt > pkt_end */
  7051                  if (pkt->range == BEYOND_PKT_END)
  7052                          /* pkt has at last one extra byte beyond 
pkt_end */
  7053                          return opcode == BPF_JGT;
  7054                  break;
  7055          case BPF_JLT:
  7056                  /* pkt < pkt_end */
  7057                  fallthrough;
  7058          case BPF_JGE:
  7059                  /* pkt >= pkt_end */
  7060                  if (pkt->range == BEYOND_PKT_END || pkt->range == 
AT_PKT_END)
  7061                          return opcode == BPF_JGE;
  7062                  break;
  7063          }
  7064          return -1;
  7065  }
  7066  

---
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