[xen stable-4.6] arm/mm: release grant lock on xenmem_add_to_physmap_one() error paths

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen stable-4.6] arm/mm: release grant lock on xenmem_add_to_physmap_one() error paths

patchbot
commit 64c03bbacfb099f464c0fe0850ece71d4007d0ea
Author:     Jan Beulich <[hidden email]>
AuthorDate: Wed Aug 23 17:55:08 2017 +0200
Commit:     Jan Beulich <[hidden email]>
CommitDate: Wed Aug 23 17:55:08 2017 +0200

    arm/mm: release grant lock on xenmem_add_to_physmap_one() error paths
   
    Commit 55021ff9ab ("xen/arm: add_to_physmap_one: Avoid to map mfn 0 if
    an error occurs") introduced error paths not releasing the grant table
    lock. Replace them by a suitable check after the lock was dropped.
   
    This is XSA-235.
   
    Reported-by: Wei Liu <[hidden email]>
    Signed-off-by: Jan Beulich <[hidden email]>
    Reviewed-by: Julien Grall <[hidden email]>
    master commit: 59546c1897a90fe9af5ebbbb05ead8d98b4d17b9
    master date: 2017-08-23 17:45:45 +0200
---
 xen/arch/arm/mm.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index f20b082..814dbdf 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1073,7 +1073,7 @@ int xenmem_add_to_physmap_one(
             if ( idx < nr_status_frames(d->grant_table) )
                 mfn = virt_to_mfn(d->grant_table->status[idx]);
             else
-                return -EINVAL;
+                mfn = INVALID_MFN;
         }
         else
         {
@@ -1084,14 +1084,21 @@ int xenmem_add_to_physmap_one(
             if ( idx < nr_grant_frames(d->grant_table) )
                 mfn = virt_to_mfn(d->grant_table->shared_raw[idx]);
             else
-                return -EINVAL;
+                mfn = INVALID_MFN;
         }
         
-        d->arch.grant_table_gpfn[idx] = gpfn;
+        if ( mfn != INVALID_MFN )
+        {
+            d->arch.grant_table_gpfn[idx] = gpfn;
 
-        t = p2m_ram_rw;
+            t = p2m_ram_rw;
+        }
 
         write_unlock(&d->grant_table->lock);
+
+        if ( mfn == INVALID_MFN )
+            return -EINVAL;
+
         break;
     case XENMAPSPACE_shared_info:
         if ( idx != 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.6

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog