Re: [PATCH bpf-next v4 2/8] bpf: Introduce global percpu data

Leon Hwang
2026-04-17T01:30:49Z

On 15/4/26 10:19, Alexei Starovoitov wrote:
> On Tue, Apr 14, 2026 at 10:19:22PM +0800, Leon Hwang wrote:
>> On 2026/4/14 22:10, bot+bpf-ci@kernel.org wrote:
[...]
>>> In the v3 series, bpf_map_direct_read() itself had a guard
>>> (map->map_type != BPF_MAP_TYPE_ARRAY), which protected all callers.
>>> The v4 moved this to caller-side checks but appears to have missed
>>> const_reg_xfer().
>>>
>>>
>> Correct.
>>
>> Will add a guard in bpf_map_direct_read() in the next revision:
>>
>> if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY)
>> return -EINVAL;
>
> hold on.
> map->ops->map_direct_value_addr &&
> - map->map_type != BPF_MAP_TYPE_INSN_ARRAY) {
> + map->map_type != BPF_MAP_TYPE_INSN_ARRAY &&
> + map->map_type != BPF_MAP_TYPE_PERCPU_ARRAY) {
>
> map_direct_value_addr() is set, but then immediately disallowed ?
> Where else it's used?
>
> Even if value_addr is working, then map_direct_value_meta() looks broken.
>

Ah, let me dive deeper.

Thanks,
Leon