Re: [PATCH bpf] bpf: Add missed allocation hint for bpf_mem_cache_alloc_flags()

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

 



Hi,

On 11/13/2023 3:23 AM, Stanislav Fomichev wrote:
> On 11/11, Hou Tao wrote:
>> From: Hou Tao <houtao1@xxxxxxxxxx>
>>
>> bpf_mem_cache_alloc_flags() may call __alloc() directly when there is no
>> free object in free list, but it doesn't initialize the allocation hint
>> for the returned pointer. It may lead to bad memory dereference when
>> freeing the pointer, so fix it by initializing the allocation hint.
>>
>> Fixes: 822fb26bdb55 ("bpf: Add a hint to allocated objects.")
>> Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
> Makes sense from briefly looking at the code. But I'll defer to Alexei
> on this one. There is also __alloc call from alloc_bulk and I can't
> quickly grasp why you're fixing this single place only.

alloc_bulk() will allocate new objects through __alloc() and add these
objects into free_llist. When unit_alloc() gets free object from
free_llist, it has already assign the allocation hint for the allocated
object.

> .





[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