From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [RFC PATCH bpf-next v2 3/9] bpf: Replace RET_XXX_OR_NULL with RET_XXX | PTR_MAYBE_NULL
Date: Tue, 30 Nov 2021 10:59:59 +0800 [thread overview]
Message-ID: <202111301041.Xvx6affN-lkp@intel.com> (raw)
In-Reply-To: <20211130012948.380602-4-haoluo@google.com>
[-- Attachment #1: Type: text/plain, Size: 24756 bytes --]
Hi Hao,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Hao-Luo/Introduce-composable-bpf-types/20211130-093143
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20211130/202111301041.Xvx6affN-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/5af019e76ba5485e0b56b5b4607c9d2e30ca6138
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hao-Luo/Introduce-composable-bpf-types/20211130-093143
git checkout 5af019e76ba5485e0b56b5b4607c9d2e30ca6138
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash kernel/bpf/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
kernel/bpf/verifier.c: In function 'check_helper_call':
>> kernel/bpf/verifier.c:6597:39: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
6597 | verbose(env, "invalid return type %d of func %s#%d\n",
| ~^
| |
| int
| %ld
kernel/bpf/verifier.c:6608:38: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
6608 | verbose(env, "unknown return type %d of func %s#%d\n",
| ~^
| |
| int
| %ld
vim +6597 kernel/bpf/verifier.c
9b99edcae5c80c Jiri Olsa 2021-07-14 6373
69c087ba6225b5 Yonghong Song 2021-02-26 6374 static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
69c087ba6225b5 Yonghong Song 2021-02-26 6375 int *insn_idx_p)
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6376 {
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6377 const struct bpf_func_proto *fn = NULL;
5af019e76ba548 Hao Luo 2021-11-29 6378 enum bpf_return_type ret_type;
638f5b90d46016 Alexei Starovoitov 2017-10-31 6379 struct bpf_reg_state *regs;
33ff9823c569f3 Daniel Borkmann 2016-04-13 6380 struct bpf_call_arg_meta meta;
69c087ba6225b5 Yonghong Song 2021-02-26 6381 int insn_idx = *insn_idx_p;
969bf05eb3cedd Alexei Starovoitov 2016-05-05 6382 bool changes_data;
69c087ba6225b5 Yonghong Song 2021-02-26 6383 int i, err, func_id;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6384
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6385 /* find function prototype */
69c087ba6225b5 Yonghong Song 2021-02-26 6386 func_id = insn->imm;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6387 if (func_id < 0 || func_id >= __BPF_FUNC_MAX_ID) {
61bd5218eef349 Jakub Kicinski 2017-10-09 6388 verbose(env, "invalid func %s#%d\n", func_id_name(func_id),
61bd5218eef349 Jakub Kicinski 2017-10-09 6389 func_id);
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6390 return -EINVAL;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6391 }
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6392
00176a34d9e27a Jakub Kicinski 2017-10-16 6393 if (env->ops->get_func_proto)
5e43f899b03a34 Andrey Ignatov 2018-03-30 6394 fn = env->ops->get_func_proto(func_id, env->prog);
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6395 if (!fn) {
61bd5218eef349 Jakub Kicinski 2017-10-09 6396 verbose(env, "unknown func %s#%d\n", func_id_name(func_id),
61bd5218eef349 Jakub Kicinski 2017-10-09 6397 func_id);
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6398 return -EINVAL;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6399 }
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6400
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6401 /* eBPF programs must be GPL compatible to use GPL-ed functions */
24701ecea76b0b Daniel Borkmann 2015-03-01 6402 if (!env->prog->gpl_compatible && fn->gpl_only) {
3fe2867cdf088f Daniel Borkmann 2018-06-02 6403 verbose(env, "cannot call GPL-restricted function from non-GPL compatible program\n");
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6404 return -EINVAL;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6405 }
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6406
eae2e83e62633a Jiri Olsa 2020-08-25 6407 if (fn->allowed && !fn->allowed(env->prog)) {
eae2e83e62633a Jiri Olsa 2020-08-25 6408 verbose(env, "helper call is not allowed in probe\n");
eae2e83e62633a Jiri Olsa 2020-08-25 6409 return -EINVAL;
eae2e83e62633a Jiri Olsa 2020-08-25 6410 }
eae2e83e62633a Jiri Olsa 2020-08-25 6411
04514d13222f2c Daniel Borkmann 2017-12-14 6412 /* With LD_ABS/IND some JITs save/restore skb from r1. */
17bedab2723145 Martin KaFai Lau 2016-12-07 6413 changes_data = bpf_helper_changes_pkt_data(fn->func);
04514d13222f2c Daniel Borkmann 2017-12-14 6414 if (changes_data && fn->arg1_type != ARG_PTR_TO_CTX) {
04514d13222f2c Daniel Borkmann 2017-12-14 6415 verbose(env, "kernel subsystem misconfigured func %s#%d: r1 != ctx\n",
04514d13222f2c Daniel Borkmann 2017-12-14 6416 func_id_name(func_id), func_id);
04514d13222f2c Daniel Borkmann 2017-12-14 6417 return -EINVAL;
04514d13222f2c Daniel Borkmann 2017-12-14 6418 }
969bf05eb3cedd Alexei Starovoitov 2016-05-05 6419
33ff9823c569f3 Daniel Borkmann 2016-04-13 6420 memset(&meta, 0, sizeof(meta));
36bbef52c7eb64 Daniel Borkmann 2016-09-20 6421 meta.pkt_access = fn->pkt_access;
33ff9823c569f3 Daniel Borkmann 2016-04-13 6422
1b986589680a2a Martin KaFai Lau 2019-03-12 6423 err = check_func_proto(fn, func_id);
435faee1aae9c1 Daniel Borkmann 2016-04-13 6424 if (err) {
61bd5218eef349 Jakub Kicinski 2017-10-09 6425 verbose(env, "kernel subsystem misconfigured func %s#%d\n",
ebb676daa1a340 Thomas Graf 2016-10-27 6426 func_id_name(func_id), func_id);
435faee1aae9c1 Daniel Borkmann 2016-04-13 6427 return err;
435faee1aae9c1 Daniel Borkmann 2016-04-13 6428 }
435faee1aae9c1 Daniel Borkmann 2016-04-13 6429
d83525ca62cf8e Alexei Starovoitov 2019-01-31 6430 meta.func_id = func_id;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6431 /* check args */
523a4cf491b3c9 Dmitrii Banshchikov 2021-02-26 6432 for (i = 0; i < MAX_BPF_FUNC_REG_ARGS; i++) {
af7ec13833619e Yonghong Song 2020-06-23 6433 err = check_func_arg(env, i, &meta, fn);
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6434 if (err)
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6435 return err;
a7658e1a4164ce Alexei Starovoitov 2019-10-15 6436 }
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6437
c93552c443ebc6 Daniel Borkmann 2018-05-24 6438 err = record_func_map(env, &meta, func_id, insn_idx);
c93552c443ebc6 Daniel Borkmann 2018-05-24 6439 if (err)
c93552c443ebc6 Daniel Borkmann 2018-05-24 6440 return err;
c93552c443ebc6 Daniel Borkmann 2018-05-24 6441
d2e4c1e6c29472 Daniel Borkmann 2019-11-22 6442 err = record_func_key(env, &meta, func_id, insn_idx);
d2e4c1e6c29472 Daniel Borkmann 2019-11-22 6443 if (err)
d2e4c1e6c29472 Daniel Borkmann 2019-11-22 6444 return err;
d2e4c1e6c29472 Daniel Borkmann 2019-11-22 6445
435faee1aae9c1 Daniel Borkmann 2016-04-13 6446 /* Mark slots with STACK_MISC in case of raw mode, stack offset
435faee1aae9c1 Daniel Borkmann 2016-04-13 6447 * is inferred from register state.
435faee1aae9c1 Daniel Borkmann 2016-04-13 6448 */
435faee1aae9c1 Daniel Borkmann 2016-04-13 6449 for (i = 0; i < meta.access_size; i++) {
ca36960211eb22 Daniel Borkmann 2018-02-23 6450 err = check_mem_access(env, insn_idx, meta.regno, i, BPF_B,
ca36960211eb22 Daniel Borkmann 2018-02-23 6451 BPF_WRITE, -1, false);
435faee1aae9c1 Daniel Borkmann 2016-04-13 6452 if (err)
435faee1aae9c1 Daniel Borkmann 2016-04-13 6453 return err;
435faee1aae9c1 Daniel Borkmann 2016-04-13 6454 }
435faee1aae9c1 Daniel Borkmann 2016-04-13 6455
fd978bf7fd3125 Joe Stringer 2018-10-02 6456 if (func_id == BPF_FUNC_tail_call) {
fd978bf7fd3125 Joe Stringer 2018-10-02 6457 err = check_reference_leak(env);
fd978bf7fd3125 Joe Stringer 2018-10-02 6458 if (err) {
fd978bf7fd3125 Joe Stringer 2018-10-02 6459 verbose(env, "tail_call would lead to reference leak\n");
fd978bf7fd3125 Joe Stringer 2018-10-02 6460 return err;
fd978bf7fd3125 Joe Stringer 2018-10-02 6461 }
fd978bf7fd3125 Joe Stringer 2018-10-02 6462 } else if (is_release_function(func_id)) {
1b986589680a2a Martin KaFai Lau 2019-03-12 6463 err = release_reference(env, meta.ref_obj_id);
46f8bc92758c62 Martin KaFai Lau 2019-02-09 6464 if (err) {
46f8bc92758c62 Martin KaFai Lau 2019-02-09 6465 verbose(env, "func %s#%d reference has not been acquired before\n",
46f8bc92758c62 Martin KaFai Lau 2019-02-09 6466 func_id_name(func_id), func_id);
fd978bf7fd3125 Joe Stringer 2018-10-02 6467 return err;
fd978bf7fd3125 Joe Stringer 2018-10-02 6468 }
46f8bc92758c62 Martin KaFai Lau 2019-02-09 6469 }
fd978bf7fd3125 Joe Stringer 2018-10-02 6470
638f5b90d46016 Alexei Starovoitov 2017-10-31 6471 regs = cur_regs(env);
cd339431765383 Roman Gushchin 2018-08-02 6472
cd339431765383 Roman Gushchin 2018-08-02 6473 /* check that flags argument in get_local_storage(map, flags) is 0,
cd339431765383 Roman Gushchin 2018-08-02 6474 * this is required because get_local_storage() can't return an error.
cd339431765383 Roman Gushchin 2018-08-02 6475 */
cd339431765383 Roman Gushchin 2018-08-02 6476 if (func_id == BPF_FUNC_get_local_storage &&
cd339431765383 Roman Gushchin 2018-08-02 6477 !register_is_null(®s[BPF_REG_2])) {
cd339431765383 Roman Gushchin 2018-08-02 6478 verbose(env, "get_local_storage() doesn't support non-zero flags\n");
cd339431765383 Roman Gushchin 2018-08-02 6479 return -EINVAL;
cd339431765383 Roman Gushchin 2018-08-02 6480 }
cd339431765383 Roman Gushchin 2018-08-02 6481
69c087ba6225b5 Yonghong Song 2021-02-26 6482 if (func_id == BPF_FUNC_for_each_map_elem) {
69c087ba6225b5 Yonghong Song 2021-02-26 6483 err = __check_func_call(env, insn, insn_idx_p, meta.subprogno,
69c087ba6225b5 Yonghong Song 2021-02-26 6484 set_map_elem_callback_state);
69c087ba6225b5 Yonghong Song 2021-02-26 6485 if (err < 0)
69c087ba6225b5 Yonghong Song 2021-02-26 6486 return -EINVAL;
69c087ba6225b5 Yonghong Song 2021-02-26 6487 }
69c087ba6225b5 Yonghong Song 2021-02-26 6488
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6489 if (func_id == BPF_FUNC_timer_set_callback) {
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6490 err = __check_func_call(env, insn, insn_idx_p, meta.subprogno,
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6491 set_timer_callback_state);
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6492 if (err < 0)
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6493 return -EINVAL;
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6494 }
b00628b1c7d595 Alexei Starovoitov 2021-07-14 6495
7c7e3d31e7856a Song Liu 2021-11-05 6496 if (func_id == BPF_FUNC_find_vma) {
7c7e3d31e7856a Song Liu 2021-11-05 6497 err = __check_func_call(env, insn, insn_idx_p, meta.subprogno,
7c7e3d31e7856a Song Liu 2021-11-05 6498 set_find_vma_callback_state);
7c7e3d31e7856a Song Liu 2021-11-05 6499 if (err < 0)
7c7e3d31e7856a Song Liu 2021-11-05 6500 return -EINVAL;
7c7e3d31e7856a Song Liu 2021-11-05 6501 }
7c7e3d31e7856a Song Liu 2021-11-05 6502
7b15523a989b63 Florent Revest 2021-04-19 6503 if (func_id == BPF_FUNC_snprintf) {
7b15523a989b63 Florent Revest 2021-04-19 6504 err = check_bpf_snprintf_call(env, regs);
7b15523a989b63 Florent Revest 2021-04-19 6505 if (err < 0)
7b15523a989b63 Florent Revest 2021-04-19 6506 return err;
7b15523a989b63 Florent Revest 2021-04-19 6507 }
7b15523a989b63 Florent Revest 2021-04-19 6508
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6509 /* reset caller saved regs */
dc503a8ad98474 Edward Cree 2017-08-15 6510 for (i = 0; i < CALLER_SAVED_REGS; i++) {
61bd5218eef349 Jakub Kicinski 2017-10-09 6511 mark_reg_not_init(env, regs, caller_saved[i]);
dc503a8ad98474 Edward Cree 2017-08-15 6512 check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
dc503a8ad98474 Edward Cree 2017-08-15 6513 }
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6514
5327ed3d44b754 Jiong Wang 2019-05-24 6515 /* helper call returns 64-bit value. */
5327ed3d44b754 Jiong Wang 2019-05-24 6516 regs[BPF_REG_0].subreg_def = DEF_NOT_SUBREG;
5327ed3d44b754 Jiong Wang 2019-05-24 6517
dc503a8ad98474 Edward Cree 2017-08-15 6518 /* update return register (already marked as written above) */
5af019e76ba548 Hao Luo 2021-11-29 6519 ret_type = fn->ret_type;
5af019e76ba548 Hao Luo 2021-11-29 6520 if (ret_type == RET_INTEGER) {
f1174f77b50c94 Edward Cree 2017-08-07 6521 /* sets type to SCALAR_VALUE */
61bd5218eef349 Jakub Kicinski 2017-10-09 6522 mark_reg_unknown(env, regs, BPF_REG_0);
5af019e76ba548 Hao Luo 2021-11-29 6523 } else if (ret_type == RET_VOID) {
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6524 regs[BPF_REG_0].type = NOT_INIT;
5af019e76ba548 Hao Luo 2021-11-29 6525 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_MAP_VALUE) {
f1174f77b50c94 Edward Cree 2017-08-07 6526 /* There is no offset yet applied, variable or fixed */
61bd5218eef349 Jakub Kicinski 2017-10-09 6527 mark_reg_known_zero(env, regs, BPF_REG_0);
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6528 /* remember map_ptr, so that check_map_access()
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6529 * can check 'value_size' boundary of memory access
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6530 * to map element returned from bpf_map_lookup_elem()
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6531 */
33ff9823c569f3 Daniel Borkmann 2016-04-13 6532 if (meta.map_ptr == NULL) {
61bd5218eef349 Jakub Kicinski 2017-10-09 6533 verbose(env,
61bd5218eef349 Jakub Kicinski 2017-10-09 6534 "kernel subsystem misconfigured verifier\n");
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6535 return -EINVAL;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6536 }
33ff9823c569f3 Daniel Borkmann 2016-04-13 6537 regs[BPF_REG_0].map_ptr = meta.map_ptr;
3e8ce29850f183 Alexei Starovoitov 2021-07-14 6538 regs[BPF_REG_0].map_uid = meta.map_uid;
5af019e76ba548 Hao Luo 2021-11-29 6539 if (ret_type_may_be_null(fn->ret_type)) {
5af019e76ba548 Hao Luo 2021-11-29 6540 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL;
5af019e76ba548 Hao Luo 2021-11-29 6541 } else {
4d31f30148cea6 Daniel Borkmann 2018-11-01 6542 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE;
e16d2f1ab96849 Alexei Starovoitov 2019-01-31 6543 if (map_value_has_spin_lock(meta.map_ptr))
e16d2f1ab96849 Alexei Starovoitov 2019-01-31 6544 regs[BPF_REG_0].id = ++env->id_gen;
4d31f30148cea6 Daniel Borkmann 2018-11-01 6545 }
5af019e76ba548 Hao Luo 2021-11-29 6546 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_SOCKET) {
46f8bc92758c62 Martin KaFai Lau 2019-02-09 6547 mark_reg_known_zero(env, regs, BPF_REG_0);
46f8bc92758c62 Martin KaFai Lau 2019-02-09 6548 regs[BPF_REG_0].type = PTR_TO_SOCKET_OR_NULL;
5af019e76ba548 Hao Luo 2021-11-29 6549 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_SOCK_COMMON) {
85a51f8c28b981 Lorenz Bauer 2019-03-22 6550 mark_reg_known_zero(env, regs, BPF_REG_0);
85a51f8c28b981 Lorenz Bauer 2019-03-22 6551 regs[BPF_REG_0].type = PTR_TO_SOCK_COMMON_OR_NULL;
5af019e76ba548 Hao Luo 2021-11-29 6552 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_TCP_SOCK) {
655a51e536c09d Martin KaFai Lau 2019-02-09 6553 mark_reg_known_zero(env, regs, BPF_REG_0);
655a51e536c09d Martin KaFai Lau 2019-02-09 6554 regs[BPF_REG_0].type = PTR_TO_TCP_SOCK_OR_NULL;
5af019e76ba548 Hao Luo 2021-11-29 6555 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_ALLOC_MEM) {
457f44363a8894 Andrii Nakryiko 2020-05-29 6556 mark_reg_known_zero(env, regs, BPF_REG_0);
457f44363a8894 Andrii Nakryiko 2020-05-29 6557 regs[BPF_REG_0].type = PTR_TO_MEM_OR_NULL;
457f44363a8894 Andrii Nakryiko 2020-05-29 6558 regs[BPF_REG_0].mem_size = meta.mem_size;
5af019e76ba548 Hao Luo 2021-11-29 6559 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_MEM_OR_BTF_ID) {
eaa6bcb71ef6ed Hao Luo 2020-09-29 6560 const struct btf_type *t;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6561
eaa6bcb71ef6ed Hao Luo 2020-09-29 6562 mark_reg_known_zero(env, regs, BPF_REG_0);
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6563 t = btf_type_skip_modifiers(meta.ret_btf, meta.ret_btf_id, NULL);
eaa6bcb71ef6ed Hao Luo 2020-09-29 6564 if (!btf_type_is_struct(t)) {
eaa6bcb71ef6ed Hao Luo 2020-09-29 6565 u32 tsize;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6566 const struct btf_type *ret;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6567 const char *tname;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6568
eaa6bcb71ef6ed Hao Luo 2020-09-29 6569 /* resolve the type size of ksym. */
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6570 ret = btf_resolve_size(meta.ret_btf, t, &tsize);
eaa6bcb71ef6ed Hao Luo 2020-09-29 6571 if (IS_ERR(ret)) {
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6572 tname = btf_name_by_offset(meta.ret_btf, t->name_off);
eaa6bcb71ef6ed Hao Luo 2020-09-29 6573 verbose(env, "unable to resolve the size of type '%s': %ld\n",
eaa6bcb71ef6ed Hao Luo 2020-09-29 6574 tname, PTR_ERR(ret));
eaa6bcb71ef6ed Hao Luo 2020-09-29 6575 return -EINVAL;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6576 }
63d9b80dcf2c67 Hao Luo 2020-09-29 6577 regs[BPF_REG_0].type =
5af019e76ba548 Hao Luo 2021-11-29 6578 (ret_type & PTR_MAYBE_NULL) ?
5af019e76ba548 Hao Luo 2021-11-29 6579 PTR_TO_MEM_OR_NULL : PTR_TO_MEM;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6580 regs[BPF_REG_0].mem_size = tsize;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6581 } else {
63d9b80dcf2c67 Hao Luo 2020-09-29 6582 regs[BPF_REG_0].type =
5af019e76ba548 Hao Luo 2021-11-29 6583 (ret_type & PTR_MAYBE_NULL) ?
5af019e76ba548 Hao Luo 2021-11-29 6584 PTR_TO_BTF_ID_OR_NULL : PTR_TO_BTF_ID;
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6585 regs[BPF_REG_0].btf = meta.ret_btf;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6586 regs[BPF_REG_0].btf_id = meta.ret_btf_id;
eaa6bcb71ef6ed Hao Luo 2020-09-29 6587 }
5af019e76ba548 Hao Luo 2021-11-29 6588 } else if (BPF_BASE_TYPE(ret_type) == RET_PTR_TO_BTF_ID) {
af7ec13833619e Yonghong Song 2020-06-23 6589 int ret_btf_id;
af7ec13833619e Yonghong Song 2020-06-23 6590
af7ec13833619e Yonghong Song 2020-06-23 6591 mark_reg_known_zero(env, regs, BPF_REG_0);
5af019e76ba548 Hao Luo 2021-11-29 6592 regs[BPF_REG_0].type = (ret_type & PTR_MAYBE_NULL) ?
5af019e76ba548 Hao Luo 2021-11-29 6593 PTR_TO_BTF_ID_OR_NULL :
5af019e76ba548 Hao Luo 2021-11-29 6594 PTR_TO_BTF_ID;
af7ec13833619e Yonghong Song 2020-06-23 6595 ret_btf_id = *fn->ret_btf_id;
af7ec13833619e Yonghong Song 2020-06-23 6596 if (ret_btf_id == 0) {
af7ec13833619e Yonghong Song 2020-06-23 @6597 verbose(env, "invalid return type %d of func %s#%d\n",
5af019e76ba548 Hao Luo 2021-11-29 6598 BPF_BASE_TYPE(ret_type), func_id_name(func_id),
5af019e76ba548 Hao Luo 2021-11-29 6599 func_id);
af7ec13833619e Yonghong Song 2020-06-23 6600 return -EINVAL;
af7ec13833619e Yonghong Song 2020-06-23 6601 }
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6602 /* current BPF helper definitions are only coming from
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6603 * built-in code with type IDs from vmlinux BTF
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6604 */
22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6605 regs[BPF_REG_0].btf = btf_vmlinux;
af7ec13833619e Yonghong Song 2020-06-23 6606 regs[BPF_REG_0].btf_id = ret_btf_id;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6607 } else {
61bd5218eef349 Jakub Kicinski 2017-10-09 6608 verbose(env, "unknown return type %d of func %s#%d\n",
5af019e76ba548 Hao Luo 2021-11-29 6609 BPF_BASE_TYPE(ret_type), func_id_name(func_id), func_id);
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6610 return -EINVAL;
17a5267067f3c3 Alexei Starovoitov 2014-09-26 6611 }
04fd61ab36ec06 Alexei Starovoitov 2015-05-19 6612
93c230e3f5bd6e Martin KaFai Lau 2020-10-19 6613 if (reg_type_may_be_null(regs[BPF_REG_0].type))
93c230e3f5bd6e Martin KaFai Lau 2020-10-19 6614 regs[BPF_REG_0].id = ++env->id_gen;
93c230e3f5bd6e Martin KaFai Lau 2020-10-19 6615
0f3adc288df8ba Lorenz Bauer 2019-03-22 6616 if (is_ptr_cast_function(func_id)) {
1b986589680a2a Martin KaFai Lau 2019-03-12 6617 /* For release_reference() */
1b986589680a2a Martin KaFai Lau 2019-03-12 6618 regs[BPF_REG_0].ref_obj_id = meta.ref_obj_id;
64d85290d79c06 Jakub Sitnicki 2020-04-29 6619 } else if (is_acquire_function(func_id, meta.map_ptr)) {
0f3adc288df8ba Lorenz Bauer 2019-03-22 6620 int id = acquire_reference_state(env, insn_idx);
0f3adc288df8ba Lorenz Bauer 2019-03-22 6621
0f3adc288df8ba Lorenz Bauer 2019-03-22 6622 if (id < 0)
0f3adc288df8ba Lorenz Bauer 2019-03-22 6623 return id;
0f3adc288df8ba Lorenz Bauer 2019-03-22 6624 /* For mark_ptr_or_null_reg() */
0f3adc288df8ba Lorenz Bauer 2019-03-22 6625 regs[BPF_REG_0].id = id;
0f3adc288df8ba Lorenz Bauer 2019-03-22 6626 /* For release_reference() */
0f3adc288df8ba Lorenz Bauer 2019-03-22 6627 regs[BPF_REG_0].ref_obj_id = id;
0f3adc288df8ba Lorenz Bauer 2019-03-22 6628 }
1b986589680a2a Martin KaFai Lau 2019-03-12 6629
849fa50662fbc8 Yonghong Song 2018-04-28 6630 do_refine_retval_range(regs, fn->ret_type, func_id, &meta);
849fa50662fbc8 Yonghong Song 2018-04-28 6631
61bd5218eef349 Jakub Kicinski 2017-10-09 6632 err = check_map_func_compatibility(env, meta.map_ptr, func_id);
35578d79840030 Kaixu Xia 2015-08-06 6633 if (err)
35578d79840030 Kaixu Xia 2015-08-06 6634 return err;
04fd61ab36ec06 Alexei Starovoitov 2015-05-19 6635
fa28dcb82a38f8 Song Liu 2020-06-29 6636 if ((func_id == BPF_FUNC_get_stack ||
fa28dcb82a38f8 Song Liu 2020-06-29 6637 func_id == BPF_FUNC_get_task_stack) &&
fa28dcb82a38f8 Song Liu 2020-06-29 6638 !env->prog->has_callchain_buf) {
c195651e565ae7 Yonghong Song 2018-04-28 6639 const char *err_str;
c195651e565ae7 Yonghong Song 2018-04-28 6640
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
next prev parent reply other threads:[~2021-11-30 2:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 1:29 [RFC PATCH bpf-next v2 0/9] Introduce composable bpf types Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 1/9] bpf: Introduce composable reg, ret and arg types Hao Luo
2021-12-01 20:29 ` Alexei Starovoitov
2021-12-01 22:36 ` Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 2/9] bpf: Replace ARG_XXX_OR_NULL with ARG_XXX | PTR_MAYBE_NULL Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 3/9] bpf: Replace RET_XXX_OR_NULL with RET_XXX " Hao Luo
2021-11-30 2:59 ` kernel test robot [this message]
2021-11-30 3:40 ` kernel test robot
2021-11-30 3:40 ` kernel test robot
2021-12-01 20:30 ` Alexei Starovoitov
2021-12-01 22:40 ` Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 4/9] bpf: Replace PTR_TO_XXX_OR_NULL with PTR_TO_XXX " Hao Luo
2021-11-30 3:30 ` kernel test robot
2021-11-30 4:21 ` kernel test robot
2021-11-30 4:21 ` kernel test robot
2021-11-30 4:31 ` kernel test robot
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 5/9] bpf: Introduce MEM_RDONLY flag Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 6/9] bpf: Convert PTR_TO_MEM_OR_NULL to composable types Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 7/9] bpf: Make per_cpu_ptr return rdonly PTR_TO_MEM Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 8/9] bpf: Add MEM_RDONLY for helper args that are pointers to rdonly mem Hao Luo
2021-12-01 20:34 ` Alexei Starovoitov
2021-12-01 22:21 ` Hao Luo
2021-12-02 3:53 ` Alexei Starovoitov
2021-12-02 18:42 ` Hao Luo
2021-12-02 21:13 ` Alexei Starovoitov
2021-12-03 0:14 ` Hao Luo
2021-11-30 1:29 ` [RFC PATCH bpf-next v2 9/9] bpf/selftests: Test PTR_TO_RDONLY_MEM Hao Luo
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=202111301041.Xvx6affN-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@lists.01.org \
/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 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.