From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3099309859171542662==" MIME-Version: 1.0 From: kernel test robot 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 Message-ID: <202111301041.Xvx6affN-lkp@intel.com> In-Reply-To: <20211130012948.380602-4-haoluo@google.com> List-Id: --===============3099309859171542662== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-composab= le-bpf-types/20211130-093143 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git ma= ster config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/202111= 30/202111301041.Xvx6affN-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=3D1 build): # https://github.com/0day-ci/linux/commit/5af019e76ba5485e0b56b5b46= 07c9d2e30ca6138 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Hao-Luo/Introduce-composable-bpf-t= ypes/20211130-093143 git checkout 5af019e76ba5485e0b56b5b4607c9d2e30ca6138 # save the config file to linux build tree mkdir build_dir make W=3D1 O=3Dbuild_dir ARCH=3Dx86_64 SHELL=3D/bin/bash kernel/bpf/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot 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=3D] 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=3D] 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_helpe= r_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 =3D 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_m= eta meta; 69c087ba6225b5 Yonghong Song 2021-02-26 6381 int insn_idx =3D *ins= n_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 prot= otype */ 69c087ba6225b5 Yonghong Song 2021-02-26 6386 func_id =3D insn->imm; 17a5267067f3c3 Alexei Starovoitov 2014-09-26 6387 if (func_id < 0 || fu= nc_id >=3D __BPF_FUNC_MAX_ID) { 61bd5218eef349 Jakub Kicinski 2017-10-09 6388 verbose(env, "invali= d 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_fun= c_proto) 5e43f899b03a34 Andrey Ignatov 2018-03-30 6394 fn =3D 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, "unknow= n 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_c= ompatible && 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 && !f= n->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 so= me JITs save/restore skb from r1. */ 17bedab2723145 Martin KaFai Lau 2016-12-07 6413 changes_data =3D bpf_= helper_changes_pkt_data(fn->func); 04514d13222f2c Daniel Borkmann 2017-12-14 6414 if (changes_data && f= n->arg1_type !=3D ARG_PTR_TO_CTX) { 04514d13222f2c Daniel Borkmann 2017-12-14 6415 verbose(env, "kernel= subsystem misconfigured func %s#%d: r1 !=3D ctx\n", 04514d13222f2c Daniel Borkmann 2017-12-14 6416 func_id_name(func_i= d), 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, size= of(meta)); 36bbef52c7eb64 Daniel Borkmann 2016-09-20 6421 meta.pkt_access =3D f= n->pkt_access; 33ff9823c569f3 Daniel Borkmann 2016-04-13 6422 = 1b986589680a2a Martin KaFai Lau 2019-03-12 6423 err =3D check_func_pr= oto(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_i= d), 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 =3D func= _id; 17a5267067f3c3 Alexei Starovoitov 2014-09-26 6431 /* check args */ 523a4cf491b3c9 Dmitrii Banshchikov 2021-02-26 6432 for (i =3D 0; i < MAX= _BPF_FUNC_REG_ARGS; i++) { af7ec13833619e Yonghong Song 2020-06-23 6433 err =3D check_func_a= rg(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 =3D record_func_m= ap(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 =3D record_func_k= ey(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 ST= ACK_MISC in case of raw mode, stack offset 435faee1aae9c1 Daniel Borkmann 2016-04-13 6447 * is inferred from r= egister state. 435faee1aae9c1 Daniel Borkmann 2016-04-13 6448 */ 435faee1aae9c1 Daniel Borkmann 2016-04-13 6449 for (i =3D 0; i < met= a.access_size; i++) { ca36960211eb22 Daniel Borkmann 2018-02-23 6450 err =3D check_mem_ac= cess(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 =3D=3D BP= F_FUNC_tail_call) { fd978bf7fd3125 Joe Stringer 2018-10-02 6457 err =3D check_refere= nce_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 =3D release_refe= rence(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 =3D cur_regs(env= ); cd339431765383 Roman Gushchin 2018-08-02 6472 = cd339431765383 Roman Gushchin 2018-08-02 6473 /* check that flags a= rgument in get_local_storage(map, flags) is 0, cd339431765383 Roman Gushchin 2018-08-02 6474 * this is required b= ecause 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 =3D=3D BP= F_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_lo= cal_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 =3D=3D BP= F_FUNC_for_each_map_elem) { 69c087ba6225b5 Yonghong Song 2021-02-26 6483 err =3D __check_func= _call(env, insn, insn_idx_p, meta.subprogno, 69c087ba6225b5 Yonghong Song 2021-02-26 6484 set_map_elem_call= back_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 =3D=3D BP= F_FUNC_timer_set_callback) { b00628b1c7d595 Alexei Starovoitov 2021-07-14 6490 err =3D __check_func= _call(env, insn, insn_idx_p, meta.subprogno, b00628b1c7d595 Alexei Starovoitov 2021-07-14 6491 set_timer_callbac= k_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 =3D=3D BP= F_FUNC_find_vma) { 7c7e3d31e7856a Song Liu 2021-11-05 6497 err =3D __check_func= _call(env, insn, insn_idx_p, meta.subprogno, 7c7e3d31e7856a Song Liu 2021-11-05 6498 set_find_vma_call= back_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 =3D=3D BP= F_FUNC_snprintf) { 7b15523a989b63 Florent Revest 2021-04-19 6504 err =3D check_bpf_sn= printf_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 =3D 0; i < CAL= LER_SAVED_REGS; i++) { 61bd5218eef349 Jakub Kicinski 2017-10-09 6511 mark_reg_not_init(en= v, regs, caller_saved[i]); dc503a8ad98474 Edward Cree 2017-08-15 6512 check_reg_arg(env, c= aller_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 return= s 64-bit value. */ 5327ed3d44b754 Jiong Wang 2019-05-24 6516 regs[BPF_REG_0].subre= g_def =3D DEF_NOT_SUBREG; 5327ed3d44b754 Jiong Wang 2019-05-24 6517 = dc503a8ad98474 Edward Cree 2017-08-15 6518 /* update return regi= ster (already marked as written above) */ 5af019e76ba548 Hao Luo 2021-11-29 6519 ret_type =3D fn->ret_= type; 5af019e76ba548 Hao Luo 2021-11-29 6520 if (ret_type =3D=3D R= ET_INTEGER) { f1174f77b50c94 Edward Cree 2017-08-07 6521 /* sets type to SCAL= AR_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 = =3D=3D RET_VOID) { 17a5267067f3c3 Alexei Starovoitov 2014-09-26 6524 regs[BPF_REG_0].type= =3D NOT_INIT; 5af019e76ba548 Hao Luo 2021-11-29 6525 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D RET_PTR_TO_MAP_VALUE) { f1174f77b50c94 Edward Cree 2017-08-07 6526 /* There is no offse= t 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 re= turned from bpf_map_lookup_elem() 17a5267067f3c3 Alexei Starovoitov 2014-09-26 6531 */ 33ff9823c569f3 Daniel Borkmann 2016-04-13 6532 if (meta.map_ptr =3D= =3D 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 =3D meta.map_ptr; 3e8ce29850f183 Alexei Starovoitov 2021-07-14 6538 regs[BPF_REG_0].map_= uid =3D 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].typ= e =3D 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].typ= e =3D PTR_TO_MAP_VALUE; e16d2f1ab96849 Alexei Starovoitov 2019-01-31 6543 if (map_value_has_s= pin_lock(meta.map_ptr)) e16d2f1ab96849 Alexei Starovoitov 2019-01-31 6544 regs[BPF_REG_0].id= =3D ++env->id_gen; 4d31f30148cea6 Daniel Borkmann 2018-11-01 6545 } 5af019e76ba548 Hao Luo 2021-11-29 6546 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D 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= =3D PTR_TO_SOCKET_OR_NULL; 5af019e76ba548 Hao Luo 2021-11-29 6549 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D 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= =3D PTR_TO_SOCK_COMMON_OR_NULL; 5af019e76ba548 Hao Luo 2021-11-29 6552 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D 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= =3D PTR_TO_TCP_SOCK_OR_NULL; 5af019e76ba548 Hao Luo 2021-11-29 6555 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D 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= =3D PTR_TO_MEM_OR_NULL; 457f44363a8894 Andrii Nakryiko 2020-05-29 6558 regs[BPF_REG_0].mem_= size =3D meta.mem_size; 5af019e76ba548 Hao Luo 2021-11-29 6559 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D RET_PTR_TO_MEM_OR_BTF_ID) { eaa6bcb71ef6ed Hao Luo 2020-09-29 6560 const struct btf_typ= e *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 =3D btf_type_skip_= modifiers(meta.ret_btf, meta.ret_btf_id, NULL); eaa6bcb71ef6ed Hao Luo 2020-09-29 6564 if (!btf_type_is_str= uct(t)) { eaa6bcb71ef6ed Hao Luo 2020-09-29 6565 u32 tsize; eaa6bcb71ef6ed Hao Luo 2020-09-29 6566 const struct btf_ty= pe *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 =3D 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 =3D btf_name= _by_offset(meta.ret_btf, t->name_off); eaa6bcb71ef6ed Hao Luo 2020-09-29 6573 verbose(env, "unab= le to resolve the size of type '%s': %ld\n", eaa6bcb71ef6ed Hao Luo 2020-09-29 6574 tname, PTR_ERR(re= t)); 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].typ= e =3D 5af019e76ba548 Hao Luo 2021-11-29 6578 (ret_type & PTR_MA= YBE_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 =3D tsize; eaa6bcb71ef6ed Hao Luo 2020-09-29 6581 } else { 63d9b80dcf2c67 Hao Luo 2020-09-29 6582 regs[BPF_REG_0].typ= e =3D 5af019e76ba548 Hao Luo 2021-11-29 6583 (ret_type & PTR_MA= YBE_NULL) ? 5af019e76ba548 Hao Luo 2021-11-29 6584 PTR_TO_BTF_ID_OR_N= ULL : PTR_TO_BTF_ID; 22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6585 regs[BPF_REG_0].btf= =3D meta.ret_btf; eaa6bcb71ef6ed Hao Luo 2020-09-29 6586 regs[BPF_REG_0].btf= _id =3D meta.ret_btf_id; eaa6bcb71ef6ed Hao Luo 2020-09-29 6587 } 5af019e76ba548 Hao Luo 2021-11-29 6588 } else if (BPF_BASE_T= YPE(ret_type) =3D=3D 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= =3D (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 =3D *fn->= ret_btf_id; af7ec13833619e Yonghong Song 2020-06-23 6596 if (ret_btf_id =3D= =3D 0) { af7ec13833619e Yonghong Song 2020-06-23 @6597 verbose(env, "inval= id 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 helpe= r definitions are only coming from 22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6603 * built-in code wit= h type IDs from vmlinux BTF 22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6604 */ 22dc4a0f5ed11b Andrii Nakryiko 2020-12-03 6605 regs[BPF_REG_0].btf = =3D btf_vmlinux; af7ec13833619e Yonghong Song 2020-06-23 6606 regs[BPF_REG_0].btf_= id =3D ret_btf_id; 17a5267067f3c3 Alexei Starovoitov 2014-09-26 6607 } else { 61bd5218eef349 Jakub Kicinski 2017-10-09 6608 verbose(env, "unknow= n return type %d of func %s#%d\n", 5af019e76ba548 Hao Luo 2021-11-29 6609 BPF_BASE_TYPE(ret_t= ype), 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_n= ull(regs[BPF_REG_0].type)) 93c230e3f5bd6e Martin KaFai Lau 2020-10-19 6614 regs[BPF_REG_0].id = =3D ++env->id_gen; 93c230e3f5bd6e Martin KaFai Lau 2020-10-19 6615 = 0f3adc288df8ba Lorenz Bauer 2019-03-22 6616 if (is_ptr_cast_funct= ion(func_id)) { 1b986589680a2a Martin KaFai Lau 2019-03-12 6617 /* For release_refer= ence() */ 1b986589680a2a Martin KaFai Lau 2019-03-12 6618 regs[BPF_REG_0].ref_= obj_id =3D 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 =3D acquire_r= eference_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_n= ull_reg() */ 0f3adc288df8ba Lorenz Bauer 2019-03-22 6625 regs[BPF_REG_0].id = =3D id; 0f3adc288df8ba Lorenz Bauer 2019-03-22 6626 /* For release_refer= ence() */ 0f3adc288df8ba Lorenz Bauer 2019-03-22 6627 regs[BPF_REG_0].ref_= obj_id =3D 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_rang= e(regs, fn->ret_type, func_id, &meta); 849fa50662fbc8 Yonghong Song 2018-04-28 6631 = 61bd5218eef349 Jakub Kicinski 2017-10-09 6632 err =3D check_map_fun= c_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 =3D=3D B= PF_FUNC_get_stack || fa28dcb82a38f8 Song Liu 2020-06-29 6637 func_id =3D=3D B= PF_FUNC_get_task_stack) && fa28dcb82a38f8 Song Liu 2020-06-29 6638 !env->prog->has_c= allchain_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 --===============3099309859171542662==--