diff mbox

[v2,1/2] x86/hvm/dmop: fix EFAULT condition

Message ID 20170928103625.896-2-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Sept. 28, 2017, 10:36 a.m. UTC
The copy macro returns false when the copy fails.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Paul Durrant <paul.durrant@citrix.com>

Backport to 4.9
---
 xen/arch/x86/hvm/dm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Paul Durrant Sept. 28, 2017, 10:39 a.m. UTC | #1
> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:36
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> <wei.liu2@citrix.com>; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Paul Durrant <Paul.Durrant@citrix.com>
> Subject: [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition
> 
> The copy macro returns false when the copy fails.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Better diff stats too now :-)

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> 
> Backport to 4.9
> ---
>  xen/arch/x86/hvm/dm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index 87ef4b6ca9..9cf53b551c 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -178,11 +178,9 @@ static int modified_memory(struct domain *d,
>          struct xen_dm_op_modified_memory_extent extent;
>          unsigned int batch_nr;
>          xen_pfn_t pfn, end_pfn;
> -        int rc;
> 
> -        rc = COPY_FROM_GUEST_BUF_OFFSET(extent,
> -            bufs, EXTENTS_BUFFER, (*rem_extents - 1) * sizeof(extent));
> -        if ( rc )
> +        if ( !COPY_FROM_GUEST_BUF_OFFSET(extent, bufs, EXTENTS_BUFFER,
> +                                         (*rem_extents - 1) * sizeof(extent)) )
>              return -EFAULT;
> 
>          if ( extent.pad )
> --
> 2.11.0
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 87ef4b6ca9..9cf53b551c 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -178,11 +178,9 @@  static int modified_memory(struct domain *d,
         struct xen_dm_op_modified_memory_extent extent;
         unsigned int batch_nr;
         xen_pfn_t pfn, end_pfn;
-        int rc;
 
-        rc = COPY_FROM_GUEST_BUF_OFFSET(extent,
-            bufs, EXTENTS_BUFFER, (*rem_extents - 1) * sizeof(extent));
-        if ( rc )
+        if ( !COPY_FROM_GUEST_BUF_OFFSET(extent, bufs, EXTENTS_BUFFER,
+                                         (*rem_extents - 1) * sizeof(extent)) )
             return -EFAULT;
 
         if ( extent.pad )