[lvc-project] [PATCH] drm/amdgpu: check a user-provided number of BOs in list

Christian König christian.koenig at amd.com
Tue Apr 8 15:22:10 MSK 2025


Am 08.04.25 um 13:54 schrieb Fedor Pchelkin:
> If user can request an arbitrary size value then we should use __GFP_NOWARN
> and back on the allocator to return NULL in case it doesn't even try to
> satisfy an enormous memory allocation request (in which case it yells in
> the log without __GFP_NOWARN being passed). Maybe that would be a more
> appropriate thing here?

Using __GFP_NOWARN is most likely an incorrect approach as well, this might disable all warnings. E.g. also OOM if I'm not completely mistaken and we clearly do want those.

> Please see:
> https://lore.kernel.org/dm-devel/CAHk-=wi8Zer6tnqO-bz+WxFpMv9sPc-LxGRm_3poOtZegjhfrg@mail.gmail.com/

Linus comment is about kvmalloc(), but the code here is using kvmalloc_array() which as far as I know is explicitly made to safely allocate arrays with parameters provided by userspace.

So pre-checking those parameters in the caller once more is a bit questionable, especially since we need to spread that around to all callers of kvmalloc_array() which looks backwards considering the purpose of kvmalloc_array().

Maybe we should reduce the warning to info level for kvmalloc_array() since returning NULL when incorrect parameters are given can be perfectly handled by the caller.

Regards,
Christian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://linuxtesting.org/pipermail/lvc-project/attachments/20250408/4f3cc5a1/attachment.html>


More information about the lvc-project mailing list