tree:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
head:   16ac8a76bb641919747e8dd64d29890464df5c58
commit: 472ebdcd15ebdb8ebe20474ef1ce09abcb241e7d [8/24] netfilter: x_tables: 
check error target size too
config: alpha-defconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 472ebdcd15ebdb8ebe20474ef1ce09abcb241e7d
        # save the attached .config to linux build tree
        make.cross ARCH=alpha 

All errors (new ones prefixed by >>):

   net/netfilter/x_tables.c: In function 'xt_check_entry_offsets':
   net/netfilter/x_tables.c:814:8: error: implicit declaration of function 
'verdict_ok'; did you mean 'vprintk'? [-Werror=implicit-function-declaration]
      if (!verdict_ok(st->verdict))
           ^~~~~~~~~~
           vprintk
>> net/netfilter/x_tables.c:819:8: error: implicit declaration of function 
>> 'error_tg_ok' [-Werror=implicit-function-declaration]
      if (!error_tg_ok(t->u.target_size, sizeof(*et),
           ^~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/error_tg_ok +819 net/netfilter/x_tables.c

   741  
   742  /**
   743   * xt_check_entry_offsets - validate arp/ip/ip6t_entry
   744   *
   745   * @base: pointer to arp/ip/ip6t_entry
   746   * @elems: pointer to first xt_entry_match, i.e. ip(6)t_entry->elems
   747   * @target_offset: the arp/ip/ip6_t->target_offset
   748   * @next_offset: the arp/ip/ip6_t->next_offset
   749   *
   750   * validates that target_offset and next_offset are sane and that all
   751   * match sizes (if any) align with the target offset.
   752   *
   753   * This function does not validate the targets or matches themselves, it
   754   * only tests that all the offsets and sizes are correct, that all
   755   * match structures are aligned, and that the last structure ends where
   756   * the target structure begins.
   757   *
   758   * Also see xt_compat_check_entry_offsets for CONFIG_COMPAT version.
   759   *
   760   * The arp/ip/ip6t_entry structure @base must have passed following 
tests:
   761   * - it must point to a valid memory location
   762   * - base to base + next_offset must be accessible, i.e. not exceed 
allocated
   763   *   length.
   764   *
   765   * A well-formed entry looks like this:
   766   *
   767   * ip(6)t_entry   match [mtdata]  match [mtdata] target [tgdata] 
ip(6)t_entry
   768   * e->elems[]-----'                              |               |
   769   *                matchsize                      |               |
   770   *                                matchsize      |               |
   771   *                                               |               |
   772   * target_offset---------------------------------'               |
   773   * next_offset---------------------------------------------------'
   774   *
   775   * elems[]: flexible array member at end of ip(6)/arpt_entry struct.
   776   *          This is where matches (if any) and the target reside.
   777   * target_offset: beginning of target.
   778   * next_offset: start of the next rule; also: size of this rule.
   779   * Since targets have a minimum size, target_offset + minlen <= 
next_offset.
   780   *
   781   * Every match stores its size, sum of sizes must not exceed 
target_offset.
   782   *
   783   * Return: 0 on success, negative errno on failure.
   784   */
   785  int xt_check_entry_offsets(const void *base,
   786                             const char *elems,
   787                             unsigned int target_offset,
   788                             unsigned int next_offset)
   789  {
   790          long size_of_base_struct = elems - (const char *)base;
   791          const struct xt_entry_target *t;
   792          const char *e = base;
   793  
   794          /* target start is within the ip/ip6/arpt_entry struct */
   795          if (target_offset < size_of_base_struct)
   796                  return -EINVAL;
   797  
   798          if (target_offset + sizeof(*t) > next_offset)
   799                  return -EINVAL;
   800  
   801          t = (void *)(e + target_offset);
   802          if (t->u.target_size < sizeof(*t))
   803                  return -EINVAL;
   804  
   805          if (target_offset + t->u.target_size > next_offset)
   806                  return -EINVAL;
   807  
   808          if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0) {
   809                  const struct xt_standard_target *st = (const void *)t;
   810  
   811                  if (XT_ALIGN(target_offset + sizeof(*st)) != 
next_offset)
   812                          return -EINVAL;
   813  
 > 814                  if (!verdict_ok(st->verdict))
   815                          return -EINVAL;
   816          } else if (strcmp(t->u.user.name, XT_ERROR_TARGET) == 0) {
   817                  const struct xt_error_target *et = (const void *)t;
   818  
 > 819                  if (!error_tg_ok(t->u.target_size, sizeof(*et),
   820                                   et->errorname, sizeof(et->errorname)))
   821                          return -EINVAL;
   822          }
   823  
   824          return xt_check_entry_match(elems, base + target_offset,
   825                                      __alignof__(struct xt_entry_match));
   826  }
   827  EXPORT_SYMBOL(xt_check_entry_offsets);
   828  

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

Attachment: .config.gz
Description: application/gzip

Reply via email to