On 11/26/25 7:56 AM, Chris Mason wrote:
> 
> 
> On 11/26/25 10:24 AM, Leon Hwang wrote:
>>
>>
>> On 2025/11/26 23:11, [email protected] wrote:
>>>> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
>>>> index d84af3719..01a99e3a3 100644
>>>> --- a/include/linux/bpf.h
>>>> +++ b/include/linux/bpf.h
>>>
>>> [ ... ]
>>>
>>>> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
>>>> index 1eeb31c5b..67e9e811d 100644
>>>> --- a/kernel/bpf/arraymap.c
>>>> +++ b/kernel/bpf/arraymap.c
>>>
>>> [ ... ]
>>>
>>>> @@ -398,10 +405,11 @@ int bpf_percpu_array_update(struct bpf_map *map, 
>>>> void *key, void *value,
>>>>    struct bpf_array *array = container_of(map, struct bpf_array, map);
>>>>    u32 index = *(u32 *)key;
>>>>    void __percpu *pptr;
>>>> -  int cpu, off = 0;
>>>> +  void *ptr, *val;
>>>>    u32 size;
>>>> +  int cpu;
>>>>
>>>> -  if (unlikely(map_flags > BPF_EXIST))
>>>> +  if (unlikely((map_flags & BPF_F_LOCK) || (u32)map_flags > 
>>>> BPF_F_ALL_CPUS))
>>>>            /* unknown flags */
>>>>            return -EINVAL;
>>>>
>>>> @@ -409,7 +417,7 @@ int bpf_percpu_array_update(struct bpf_map *map, void 
>>>> *key, void *value,
>>>>            /* all elements were pre-allocated, cannot insert a new one */
>>>>            return -E2BIG;
>>>>
>>>> -  if (unlikely(map_flags & BPF_NOEXIST))
>>>> +  if (unlikely(map_flags == BPF_NOEXIST))
>>>                               ^^
>>>
>>
>> ?
>>
>> No such change in this version.
>>
>> It seems that this change was inferred from v11 to v12 by AI itself
> 
> Thanks for flagging this, I'll try to find this section of the logs to
> see how the false positive checks failed to catch it.
> 
> -chris

AI got confused here, this was not in the diff.

But it appears it got triggered, because there are these two code
fragments nearby [1]:


        if (unlikely(map_flags & BPF_NOEXIST))
                /* all elements already exist */
                return -EEXIST;

and

        if (unlikely(map_flags == BPF_NOEXIST))
                /* all elements already exist */
                return -EEXIST;

Which is a good thing to notice even if this is intentional.

Anyone knows if it is?

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/kernel/bpf/arraymap.c#n356

> 


Reply via email to