Re: [PATCH bpf] bpf, x64: Fix prog_array_map_poke_run map poke update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jiri,

kernel test robot noticed the following build errors:

[auto build test ERROR on bpf/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Jiri-Olsa/bpf-x64-Fix-prog_array_map_poke_run-map-poke-update/20231127-174900
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
patch link:    https://lore.kernel.org/r/20231127094525.1366740-1-jolsa%40kernel.org
patch subject: [PATCH bpf] bpf, x64: Fix prog_array_map_poke_run map poke update
config: i386-randconfig-061-20231127 (https://download.01.org/0day-ci/archive/20231127/202311272245.sevnkuSF-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231127/202311272245.sevnkuSF-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311272245.sevnkuSF-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

   ld: kernel/bpf/arraymap.o: in function `prog_array_map_poke_run':
>> kernel/bpf/arraymap.c:1067: undefined reference to `__bpf_arch_text_poke'
>> ld: kernel/bpf/arraymap.c:1079: undefined reference to `__bpf_arch_text_poke'
   ld: kernel/bpf/arraymap.c:1090: undefined reference to `__bpf_arch_text_poke'
   ld: kernel/bpf/arraymap.c:1072: undefined reference to `__bpf_arch_text_poke'


vim +1067 kernel/bpf/arraymap.c

  1014	
  1015	static void prog_array_map_poke_run(struct bpf_map *map, u32 key,
  1016					    struct bpf_prog *old,
  1017					    struct bpf_prog *new)
  1018	{
  1019		u8 *old_addr, *new_addr, *old_bypass_addr;
  1020		struct prog_poke_elem *elem;
  1021		struct bpf_array_aux *aux;
  1022	
  1023		aux = container_of(map, struct bpf_array, map)->aux;
  1024		WARN_ON_ONCE(!mutex_is_locked(&aux->poke_mutex));
  1025	
  1026		list_for_each_entry(elem, &aux->poke_progs, list) {
  1027			struct bpf_jit_poke_descriptor *poke;
  1028			int i, ret;
  1029	
  1030			for (i = 0; i < elem->aux->size_poke_tab; i++) {
  1031				poke = &elem->aux->poke_tab[i];
  1032	
  1033				/* Few things to be aware of:
  1034				 *
  1035				 * 1) We can only ever access aux in this context, but
  1036				 *    not aux->prog since it might not be stable yet and
  1037				 *    there could be danger of use after free otherwise.
  1038				 * 2) Initially when we start tracking aux, the program
  1039				 *    is not JITed yet and also does not have a kallsyms
  1040				 *    entry. We skip these as poke->tailcall_target_stable
  1041				 *    is not active yet. The JIT will do the final fixup
  1042				 *    before setting it stable. The various
  1043				 *    poke->tailcall_target_stable are successively
  1044				 *    activated, so tail call updates can arrive from here
  1045				 *    while JIT is still finishing its final fixup for
  1046				 *    non-activated poke entries.
  1047				 * 3) Also programs reaching refcount of zero while patching
  1048				 *    is in progress is okay since we're protected under
  1049				 *    poke_mutex and untrack the programs before the JIT
  1050				 *    buffer is freed.
  1051				 * 4) Any error happening below from __bpf_arch_text_poke()
  1052				 *    is a unexpected bug.
  1053				 */
  1054				if (!READ_ONCE(poke->tailcall_target_stable))
  1055					continue;
  1056				if (poke->reason != BPF_POKE_REASON_TAIL_CALL)
  1057					continue;
  1058				if (poke->tail_call.map != map ||
  1059				    poke->tail_call.key != key)
  1060					continue;
  1061	
  1062				old_bypass_addr = old ? NULL : poke->bypass_addr;
  1063				old_addr = old ? (u8 *)old->bpf_func + poke->adj_off : NULL;
  1064				new_addr = new ? (u8 *)new->bpf_func + poke->adj_off : NULL;
  1065	
  1066				if (new) {
> 1067					ret = __bpf_arch_text_poke(poke->tailcall_target,
  1068								 BPF_MOD_JUMP,
  1069								 old_addr, new_addr);
  1070					BUG_ON(ret < 0);
  1071					if (!old) {
  1072						ret = __bpf_arch_text_poke(poke->tailcall_bypass,
  1073									 BPF_MOD_JUMP,
  1074									 poke->bypass_addr,
  1075									 NULL);
  1076						BUG_ON(ret < 0);
  1077					}
  1078				} else {
> 1079					ret = __bpf_arch_text_poke(poke->tailcall_bypass,
  1080								 BPF_MOD_JUMP,
  1081								 old_bypass_addr,
  1082								 poke->bypass_addr);
  1083					BUG_ON(ret < 0);
  1084					/* let other CPUs finish the execution of program
  1085					 * so that it will not possible to expose them
  1086					 * to invalid nop, stack unwind, nop state
  1087					 */
  1088					if (!ret)
  1089						synchronize_rcu();
  1090					ret = __bpf_arch_text_poke(poke->tailcall_target,
  1091								 BPF_MOD_JUMP,
  1092								 old_addr, NULL);
  1093					BUG_ON(ret < 0);
  1094				}
  1095			}
  1096		}
  1097	}
  1098	

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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux