linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: oe-kbuild-all@lists.linux.dev,
	Linux Memory Management List <linux-mm@kvack.org>,
	Alexei Starovoitov <ast@kernel.org>
Subject: [linux-next:master 5430/5912] kernel/bpf/verifier.c:15232:13: warning: variable 'prev_offset' set but not used
Date: Tue, 19 Sep 2023 06:30:49 +0800	[thread overview]
Message-ID: <202309190634.fL17FWoT-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   7fc7222d9680366edeecc219c21ca96310bdbc10
commit: aaa619ebccb2b78b3c6d2c0cd72d206ee8fc0025 [5430/5912] bpf: Refactor check_btf_func and split into two phases
config: arc-randconfig-002-20230919 (https://download.01.org/0day-ci/archive/20230919/202309190634.fL17FWoT-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309190634.fL17FWoT-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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309190634.fL17FWoT-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/bpf/verifier.c: In function 'check_btf_func':
>> kernel/bpf/verifier.c:15232:13: warning: variable 'prev_offset' set but not used [-Wunused-but-set-variable]
   15232 |         u32 prev_offset = 0;
         |             ^~~~~~~~~~~
>> kernel/bpf/verifier.c:15225:35: warning: variable 'min_size' set but not used [-Wunused-but-set-variable]
   15225 |         u32 i, nfuncs, urec_size, min_size;
         |                                   ^~~~~~~~


vim +/prev_offset +15232 kernel/bpf/verifier.c

 15219	
 15220	static int check_btf_func(struct bpf_verifier_env *env,
 15221				  const union bpf_attr *attr,
 15222				  bpfptr_t uattr)
 15223	{
 15224		const struct btf_type *type, *func_proto, *ret_type;
 15225		u32 i, nfuncs, urec_size, min_size;
 15226		u32 krec_size = sizeof(struct bpf_func_info);
 15227		struct bpf_func_info *krecord;
 15228		struct bpf_func_info_aux *info_aux = NULL;
 15229		struct bpf_prog *prog;
 15230		const struct btf *btf;
 15231		bpfptr_t urecord;
 15232		u32 prev_offset = 0;
 15233		bool scalar_return;
 15234		int ret = -ENOMEM;
 15235	
 15236		nfuncs = attr->func_info_cnt;
 15237		if (!nfuncs) {
 15238			if (check_abnormal_return(env))
 15239				return -EINVAL;
 15240			return 0;
 15241		}
 15242		if (nfuncs != env->subprog_cnt) {
 15243			verbose(env, "number of funcs in func_info doesn't match number of subprogs\n");
 15244			return -EINVAL;
 15245		}
 15246	
 15247		urec_size = attr->func_info_rec_size;
 15248	
 15249		prog = env->prog;
 15250		btf = prog->aux->btf;
 15251	
 15252		urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
 15253		min_size = min_t(u32, krec_size, urec_size);
 15254	
 15255		krecord = prog->aux->func_info;
 15256		info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
 15257		if (!info_aux)
 15258			return -ENOMEM;
 15259	
 15260		for (i = 0; i < nfuncs; i++) {
 15261			/* check insn_off */
 15262			ret = -EINVAL;
 15263	
 15264			if (env->subprog_info[i].start != krecord[i].insn_off) {
 15265				verbose(env, "func_info BTF section doesn't match subprog layout in BPF program\n");
 15266				goto err_free;
 15267			}
 15268	
 15269			/* Already checked type_id */
 15270			type = btf_type_by_id(btf, krecord[i].type_id);
 15271			info_aux[i].linkage = BTF_INFO_VLEN(type->info);
 15272			/* Already checked func_proto */
 15273			func_proto = btf_type_by_id(btf, type->type);
 15274	
 15275			ret_type = btf_type_skip_modifiers(btf, func_proto->type, NULL);
 15276			scalar_return =
 15277				btf_type_is_small_int(ret_type) || btf_is_any_enum(ret_type);
 15278			if (i && !scalar_return && env->subprog_info[i].has_ld_abs) {
 15279				verbose(env, "LD_ABS is only allowed in functions that return 'int'.\n");
 15280				goto err_free;
 15281			}
 15282			if (i && !scalar_return && env->subprog_info[i].has_tail_call) {
 15283				verbose(env, "tail_call is only allowed in functions that return 'int'.\n");
 15284				goto err_free;
 15285			}
 15286	
 15287			prev_offset = krecord[i].insn_off;
 15288			bpfptr_add(&urecord, urec_size);
 15289		}
 15290	
 15291		prog->aux->func_info_aux = info_aux;
 15292		return 0;
 15293	
 15294	err_free:
 15295		kfree(info_aux);
 15296		return ret;
 15297	}
 15298	

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


             reply	other threads:[~2023-09-18 22:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 22:30 kernel test robot [this message]
2023-09-19  9:33 ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202309190634.fL17FWoT-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=ast@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=memxor@gmail.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox