Re: [PATCH v2] xen/privcmd: fix error exit of privcmd_ioctl_dm_op()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux