Skip to content

Commit

Permalink
bpf: Disable unsupported operations for map with dynptr key
Browse files Browse the repository at this point in the history
Both batched map operation and dumping the map content through bpffs for
maps with dynptr keys are not supported, so disable these operations for
now.

Signed-off-by: Hou Tao <[email protected]>
  • Loading branch information
Hou Tao authored and Kernel Patches Daemon committed Jan 25, 2025
1 parent fe35030 commit c3ef957
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ static inline bool bpf_map_offload_neutral(const struct bpf_map *map)
static inline bool bpf_map_support_seq_show(const struct bpf_map *map)
{
return (map->btf_value_type_id || map->btf_vmlinux_value_type_id) &&
map->ops->map_seq_show_elem;
map->ops->map_seq_show_elem &&
!bpf_map_has_dynptr_key(map);
}

int map_check_no_btf(const struct bpf_map *map,
Expand Down
4 changes: 4 additions & 0 deletions kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -5542,6 +5542,10 @@ static int bpf_map_do_batch(const union bpf_attr *attr,
err = -EPERM;
goto err_put;
}
if (bpf_map_has_dynptr_key(map)) {
err = -EOPNOTSUPP;
goto err_put;
}

if (cmd == BPF_MAP_LOOKUP_BATCH)
BPF_DO_BATCH(map->ops->map_lookup_batch, map, attr, uattr);
Expand Down

0 comments on commit c3ef957

Please sign in to comment.