Skip to content

Commit 89c6307

Browse files
borkmanndavem330
authored andcommitted
bpf: make htab inlining more robust wrt assumptions
Commit 9015d2f ("bpf: inline htab_map_lookup_elem()") was making the assumption that a direct call emission to the function __htab_map_lookup_elem() will always work out for JITs. This is currently true since all JITs we have are for 64 bit archs, but in case of 32 bit JITs like upcoming arm32, we get a NULL pointer dereference when executing the call to __htab_map_lookup_elem() since passed arguments are of a different size (due to pointer args) than what we do out of BPF. Guard and thus limit this for now for the current 64 bit JITs only. Reported-by: Shubham Bansal <illusionist.neo@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 06d0a11 commit 89c6307

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

kernel/bpf/verifier.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4160,7 +4160,11 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
41604160
continue;
41614161
}
41624162

4163-
if (ebpf_jit_enabled() && insn->imm == BPF_FUNC_map_lookup_elem) {
4163+
/* BPF_EMIT_CALL() assumptions in some of the map_gen_lookup
4164+
* handlers are currently limited to 64 bit only.
4165+
*/
4166+
if (ebpf_jit_enabled() && BITS_PER_LONG == 64 &&
4167+
insn->imm == BPF_FUNC_map_lookup_elem) {
41644168
map_ptr = env->insn_aux_data[i + delta].map_ptr;
41654169
if (map_ptr == BPF_MAP_PTR_POISON ||
41664170
!map_ptr->ops->map_gen_lookup)

0 commit comments

Comments
 (0)