lkml.org 
[lkml]   [2022]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] xen/privcmd: fix error exit of privcmd_ioctl_dm_op()
From
On 25.08.22 12:22, Jan Beulich wrote:
> On 25.08.2022 12:13, Juergen Gross wrote:
>> On 25.08.22 11:50, Jan Beulich wrote:
>>> On 25.08.2022 11:26, Juergen Gross wrote:
>>>> --- a/drivers/xen/privcmd.c
>>>> +++ b/drivers/xen/privcmd.c
>>>> @@ -602,6 +602,10 @@ static int lock_pages(
>>>> *pinned += page_count;
>>>> nr_pages -= page_count;
>>>> pages += page_count;
>>>> +
>>>> + /* Exact reason isn't known, EFAULT is one possibility. */
>>>> + if (page_count < requested)
>>>> + return -EFAULT;
>>>> }
>>>
>>> I don't really know the inner workings of pin_user_pages_fast()
>>> nor what future plans there are with it. To be as independent of
>>> its behavior as possible, how about bailing here only when
>>> page_count actually is zero (i.e. no forward progress)?
>>
>> This would require to rework the loop in lock_pages() to be able to
>> handle only a partial buffer.
>
> Oh, I see - I've misread the code as if the loop was capping each
> iteration's count to the capacity of some internal buffer (as iirc
> is being done elsewhere). So ...
>
>> This would add some complexity, but OTOH I'd get an exact error code
>> back in case of failure.
>
> ... perhaps not worth it then, ...
>
>> I'll have a try and see how the result would look like.
>
> ... unless you think this might be relevant in certain cases.

Not sure, but the resulting code is looking fine IMO.


Juergen
[unhandled content-type:application/pgp-keys][unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-08-25 13:14    [W:0.040 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site