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

[Xen-devel] [PATCH] flask: Add check for io{port,mem}con sorting


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
  • Date: Fri, 28 Sep 2018 15:13:27 -0400
  • Cc: George Dunlap <dunlapg@xxxxxxxxx>, Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 28 Sep 2018 19:13:42 +0000
  • Ironport-phdr: 9a23:rCKcaRfcwHsO1L9hehyoFVAXlGMj4u6mDksu8pMizoh2WeGdxcS8YR7h7PlgxGXEQZ/co6odzbaO7Oa4ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTahY75+Ngm6oRnMvcQKnIVuLbo8xAHUqXVSYeRWwm1oJVOXnxni48q74YBu/SdNtf8/7sBMSar1cbg2QrxeFzQmLns65Nb3uhnZTAuA/WUTX2MLmRdVGQfF7RX6XpDssivms+d2xSeXMdHqQb0yRD+v9LlgRgP2hygbNj456GDXhdJ2jKJHuxKquhhzz5fJbI2JKPZye6XQct0ARWpFQ81fSSpPDI2hZIcLFuYNI/pUo4z7qlATrxWxGBOsCfvvxDFWm3H406403eM6HA3awAAtBc4CvW7IoNnpMqoZTOC7zLPPzTXGd/5Y1y3y6I7Jch8/pfGHQLx+ftTMwkcuDQPKlE+fqYL4ND6Sy+sNvHWU4PRvVeK1kWEqsB1xozizyccsjYnFnIQVykve+iljz4Y1IsO4RVd9bNW5E5VQrzmXO5Z5T84tWW1luDs2xqcYtZO0YiQG0okryhjCYPKdaYeI+AjsVOOJLDd9g3JqZaywig6p8Uil1u38Ts600EtWriZdktnDqHQN1xvL58ibUPR95Eah2SuU1wzJ9uFFIVw7larcK5I7xL4/ioETvljZEi/zmUX2iLeadkQi+ue29+Tqeqjqq5CTOoNuigzyL74iltKwDOgmKAQCQnCX+eGm273i+U35Tq9KjvozkqTBrZ/aKtkUqbC2Aw9PyIku8Aq/Dje639QYmnkLNlRFeAmdgITzNFHOJ+74Ae+lg1uwiDdr2+zGPrr5D5rQM3jDlrPhcqxl605T0wcz0NVf55NIBbEBOv78RFL+tMHABB8jLwO02/rnCMl61o4GVmOAHKmZPLrPvlCW+OIgPe2MaZQRuDb8MPgl++XugWU2mFADe6mpxYEXaHe6Hvt4P0qZfWDggtAbEWcF7UICS7n6hVvHXTNNanKaW6Mn+ip9GI+gFZ3ERI2mnPqGxijoMIdRYzVqA1aNHHOgW4jMdO0FYSzadsNunjELT7GJV54q1RboshTzjbVgMLyHqWUjqZv/2Y0ttKXonhYo+GkxVp7F3g==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

These entries are not always sorted by checkpolicy.  Enforce the sorting
(which can be done manually if using an unpatched checkpolicy) when
loading the policy so that later uses by the security server do not
incorrectly use the initial sid.

Reported-by: Nicolas Poirot <nicolas.poirot@xxxxxxxxx>
Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
---
 xen/xsm/flask/ss/policydb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xen/xsm/flask/ss/policydb.c b/xen/xsm/flask/ss/policydb.c
index 3a12d96ef9..fcf63693b9 100644
--- a/xen/xsm/flask/ss/policydb.c
+++ b/xen/xsm/flask/ss/policydb.c
@@ -2007,7 +2007,6 @@ int policydb_read(struct policydb *p, void *fp)
                 l->next = c;
             else
                 p->ocontexts[i] = c;
-            l = c;
             rc = -EINVAL;
             switch ( i )
             {
@@ -2050,6 +2049,12 @@ int policydb_read(struct policydb *p, void *fp)
                 rc = context_read_and_validate(&c->context, p, fp);
                 if ( rc )
                     goto bad;
+                if ( l && l->u.ioport.high_ioport > c->u.ioport.low_ioport )
+                {
+                    printk(KERN_ERR
+                        "Flask: Invalid policy, ioportcon not sorted\n");
+                    goto bad;
+                }
                 break;
             case OCON_IOMEM:
                 if ( p->target_type != TARGET_XEN )
@@ -2078,6 +2083,12 @@ int policydb_read(struct policydb *p, void *fp)
                 rc = context_read_and_validate(&c->context, p, fp);
                 if ( rc )
                     goto bad;
+                if ( l && l->u.iomem.high_iomem > c->u.iomem.low_iomem )
+                {
+                    printk(KERN_ERR
+                        "Flask: Invalid policy, iomemcon not sorted\n");
+                    goto bad;
+                }
                 break;
             case OCON_DEVICE:
                 if ( p->target_type != TARGET_XEN )
@@ -2123,6 +2134,7 @@ int policydb_read(struct policydb *p, void *fp)
                 rc = -EINVAL;
                 goto bad;
             }
+            l = c;
         }
     }
 
-- 
2.14.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.