<div dir="ltr">Not at all, I can draft the new patch and resend. Thanks for all the useful discussion : )</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 2, 2022 at 9:36 AM Helge Deller <<a href="mailto:deller@gmx.de">deller@gmx.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On 2/2/22 18:27, Sam Ravnborg wrote:<br>
> Hi Helge,<br>
><br>
> On Tue, Feb 01, 2022 at 04:02:40PM +0100, Helge Deller wrote:<br>
>> On 1/31/22 07:57, Yizhuo Zhai wrote:<br>
>>> In function do_fb_ioctl(), the "arg" is the type of unsigned long,<br>
>><br>
>> yes, because it comes from the ioctl framework...<br>
>><br>
>>> and in "case FBIOBLANK:" this argument is casted into an int before<br>
>>> passig to fb_blank().<br>
>><br>
>> which makes sense IMHO.<br>
>><br>
>>> In fb_blank(), the comparision if (blank > FB_BLANK_POWERDOWN) would<br>
>>> be bypass if the original "arg" is a large number, which is possible<br>
>>> because it comes from the user input.<br>
>><br>
>> The main problem I see with your patch is that you change the behaviour.<br>
>> Let's assume someone passes in -1UL.<br>
>> With your patch applied, this means the -1 (which is e.g. 0xffffffff on 32bit)<br>
>> is converted to a positive integer and will be capped to FB_BLANK_POWERDOWN.<br>
>> Since most blank functions just check and react on specific values, you changed<br>
>> the behaviour that the screen now gets blanked at -1, while it wasn't before.<br>
>><br>
>> One could now argue, that it's undefined behaviour if people<br>
>> pass in wrong values, but anyway, it's different now.<br>
><br>
> We should just plug this hole and in case an illegal value is passed<br>
> then return -EINVAL.<br>
><br>
> Acceptable values are FB_BLANK_UNBLANK..FB_BLANK_POWERDOWN,<br>
> anything less than or greater than should result in -EINVAL.<br>
<br>
Yes, that's the best solution.<br>
Yizhuo Zhai, would you mind to resend with that solution?<br>
<br>
Helge<br>
<br>
> We miss this kind or early checks in many places, and we see the effect<br>
> of this in some drivers where they do it locally for no good.<br>
><br>
>       Sam<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><span style="font-size:14px">Kind Regards,</span><div style="font-size:14px"><br><div><font face="arial, helvetica, sans-serif" size="2"><b>Yizhuo Zhai</b></font></div></div><div style="font-size:14px"><br></div><div style="font-size:14px"><b>Computer Science, Graduate Student</b></div><div style="font-size:14px"><b>University of California, Riverside </b></div></div></div>