Messages in this thread | | | Date | Thu, 25 Aug 2022 13:14:20 +0200 | Subject | Re: [PATCH v2] xen/privcmd: fix error exit of privcmd_ioctl_dm_op() | From | Juergen Gross <> |
| |
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] | |