Skip to contentSkip to conversation

Xen Security Advisory 235 - add-to-physmap error paths fail to release lock on ARM

PATCH Xen.org security team 1 participant 1 message Aug 23, 2017

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Xen Security Advisory XSA-235

add-to-physmap error paths fail to release lock on ARM

ISSUE DESCRIPTION
=================

When dealing with the grant map space of add-to-physmap operations, ARM specific code recognizes a number of error conditions, but fails to release a lock being held on the respective exit paths.

IMPACT
======

A malicious guest administrator can cause a denial of service. Specifically, prevent use of a physical CPU for an indefinite period of time.

VULNERABLE SYSTEMS
==================

Xen versions 4.4 and later are vulnerable. Xen versions 4.3 and earlier are not vulnerable.

Only ARM systems are affected. X86 systems are not affected.

MITIGATION
==========

On systems where the guest kernel is controlled by the host rather than guest administrator, running only kernels which only issue sane hypercalls will prevent untrusted guest users from exploiting this issue. However untrusted guest administrators can still trigger it unless further steps are taken to prevent them from loading code into the kernel (e.g by disabling loadable modules etc) or from using other mechanisms which allow them to run code at kernel privilege.

CREDITS
=======

This issue was discovered by Wei Liu of Citrix.

RESOLUTION
==========

Applying the appropriate attached patch resolves this issue.

xsa235.patch           xen-unstable
xsa235-4.9.patch       Xen 4.9.x, Xen 4.8.x
xsa235-4.7.patch       Xen 4.7.x
xsa235-4.6.patch       Xen 4.6.x
xsa235-4.5.patch       Xen 4.5.x
$ sha256sum xsa235*
6ec8bf9462de65fee3896246f52c00941b2d83c759b3f7b28a440eb977fcbc37  xsa235.meta
c81f534e96fe38b9f77794bb143d104d66ce2d7177bda43f872642616e23df65  xsa235.patch
3c21cb1a53f5979b069568c6cd6df3aad00c19e0e459e37625d6a3c0f4f360cc  xsa235-4.5.patch
47cda4f32b65f3543af368c324a2e5b308b698a1c7d8bc84fc274eb2cdb45c0e  xsa235-4.6.patch
f30848eee71e66687b421b87be1d8e3f454c0eb395422546c62a689153d1e31c  xsa235-4.7.patch
d8f012734fbf6019c1ff864744e308c41dfb9c7804ca3be2771c2c972cdf4bd5  xsa235-4.9.patch
$

NOTE REGARDING LACK OF EMBARGO
==============================

The issue was discussed publicly before being recognized as a security issue.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBCAAGBQJZnZxeAAoJEIP+FMlX6CvZTj4IALE9/7IoG1Ak/TZuHE4xRxZx Zd2APyf+lCNj3wwdFRGC/969ilQ9OjLlJ408RyY6bVpwfmsjJTZWnAcWuS/fIdhY niillD1sdP7Eg65JG8bxL2jCaISH7AJKSePoLuc8G55I7uuJYEnipyvDZuz6W+qy k03+Bbz+TwNezA4YoNFsSpRdX48iIevFy9AIhZmggLUqdgmTR1rygjW/bxanBX8z 2dSch8LMcsVArTmwE3NnxVSJC1/g3Tc07wll7LnB6npecbCmiMqk+rhPUFdHZXl7 pYZy+Qp7w5rqcd91cOuKQKml4O3lO9ajblfpqKmbH3+hnuDqEnVlHSvVNVGWyag= =mGPq
-----END PGP SIGNATURE-----

From: Jan Beulich <[email protected]>
Subject: 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.

xen/arch/arm/mm.c +9 -6
@@ -1240,8 +1240,6 @@ int xenmem_add_to_physmap_one(
             idx &= ~XENMAPIDX_grant_table_status;
             if ( idx < nr_status_frames(d->grant_table) )
                 mfn = virt_to_mfn(d->grant_table->status[idx]);
-            else
-                return -EINVAL;
         }
         else
         {
@@ -1251,15 +1249,20 @@ 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;
         }
 
-        d->arch.grant_table_gfn[idx] = gfn;
+        if ( !mfn_eq(mfn, INVALID_MFN) )
+        {
+            d->arch.grant_table_gfn[idx] = gfn;
 
-        t = p2m_ram_rw;
+            t = p2m_ram_rw;
+        }
 
         grant_write_unlock(d->grant_table);
+
+        if ( mfn_eq(mfn, INVALID_MFN) )
+            return -EINVAL;
+
         break;
     case XENMAPSPACE_shared_info:
         if ( idx != 0 )

From: Jan Beulich <[email protected]>
Subject: 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.

xen/arch/arm/mm.c +11 -4
@@ -1052,7 +1052,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
         {
@@ -1063,14 +1063,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;
+        }
 
         spin_unlock(&d->grant_table->lock);
+
+        if ( mfn == INVALID_MFN )
+            return -EINVAL;
+
         break;
     case XENMAPSPACE_shared_info:
         if ( idx != 0 )

From: Jan Beulich <[email protected]>
Subject: 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.

xen/arch/arm/mm.c +11 -4
@@ -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 )

From: Jan Beulich <[email protected]>
Subject: 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.

xen/arch/arm/mm.c +11 -4
@@ -1081,7 +1081,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
         {
@@ -1092,14 +1092,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;
+        }
 
         grant_write_unlock(d->grant_table);
+
+        if ( mfn == INVALID_MFN )
+            return -EINVAL;
+
         break;
     case XENMAPSPACE_shared_info:
         if ( idx != 0 )

From: Jan Beulich <[email protected]>
Subject: 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.

xen/arch/arm/mm.c +11 -4
@@ -1164,7 +1164,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 = mfn_x(INVALID_MFN);
         }
         else
         {
@@ -1175,14 +1175,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 = mfn_x(INVALID_MFN);
         }
 
-        d->arch.grant_table_gfn[idx] = gfn;
+        if ( mfn != mfn_x(INVALID_MFN) )
+        {
+            d->arch.grant_table_gfn[idx] = gfn;
 
-        t = p2m_ram_rw;
+            t = p2m_ram_rw;
+        }
 
         grant_write_unlock(d->grant_table);
+
+        if ( mfn == mfn_x(INVALID_MFN) )
+            return -EINVAL;
+
         break;
     case XENMAPSPACE_shared_info:
         if ( idx != 0 )

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel