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_3pootzegjh...@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.

Reply via email to