<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Am 08.04.25 um 13:54 schrieb Fedor Pchelkin:<br>
<blockquote type="cite" cite="mid:qc72y52kt7vuwox4lhk42zligy5bslttselfoexse42mywtpps@ebqijs2tap2t"><span style="white-space: pre-wrap">
</span>
<pre class="moz-quote-pre" wrap="">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?</pre>
</blockquote>
<br>
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.<br>
<br>
<blockquote type="cite" cite="mid:qc72y52kt7vuwox4lhk42zligy5bslttselfoexse42mywtpps@ebqijs2tap2t">
<pre class="moz-quote-pre" wrap="">Please see:
<a class="moz-txt-link-freetext" href="https://lore.kernel.org/dm-devel/CAHk-=wi8Zer6tnqO-bz+WxFpMv9sPc-LxGRm_3poOtZegjhfrg@mail.gmail.com/">https://lore.kernel.org/dm-devel/CAHk-=wi8Zer6tnqO-bz+WxFpMv9sPc-LxGRm_3poOtZegjhfrg@mail.gmail.com/</a></pre>
</blockquote>
<br>
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.<br>
<br>
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().<br>
<br>
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.<br>
<br>
Regards,<br>
Christian.<br>
<br>
</body>
</html>