e_policy_wl: Raise a protocol error for a request with invalid parent 65/253965/2
authorSeunghun Lee <shiin.lee@samsung.com>
Fri, 19 Feb 2021 07:21:33 +0000 (16:21 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Mon, 22 Feb 2021 03:57:02 +0000 (12:57 +0900)
The E crashed with null pointer access to comp_data of
sub-surface's parent in _e_comp_wl_subsurface_order_commit() function.

And it turned out that the parent was an internal window created by E.
But the internal window cannot be the parent of sub-surface
theoretically. So, it is possible for wl_client to try to create
sub-surface with invalid resource ID for parent using
tizen_policy::get_subsurface protocol.

So, this patch will raise a protocol error for that case to get it
failed early.

Change-Id: I98351de962e3ea8cf5b8d218a858859929b0da5d

src/bin/e_policy_wl.c

index b799fb8d5f16b64a90c8d71164e6ee67bd8a7f61..77e0e9e9d4584edb0580ed5390d60bd41a3c511a 100644 (file)
@@ -2137,6 +2137,27 @@ _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *res
 
    epc = e_pixmap_find_client_by_res_id(parent_id);
 
+   /* This check code is for detecting an error case which tries to create
+    * sub-surface relationship with invalid parent. */
+   if ((epc) &&
+       (!e_object_is_del(E_OBJECT(epc))) &&
+       (!epc->comp_data))
+     {
+        /* Another error case is handled by e_comp_wl_subsurface_create()
+         * at the time this code is written. */
+        ELOGF("TZPOL", "Parent(%p internal? %s) doesn't have comp_data. "
+              "Possibly it's not the surface created by client. "
+              "Cannot be the parent of sub-surface.",
+              ec, epc, epc->internal ? "TRUE" : "FALSE");
+        wl_resource_post_error(resource,
+                               WL_SUBSURFACE_ERROR_BAD_SURFACE,
+                               "Invalid parent_id@%d. Possibly it's not the "
+                               "surface created by client.(internal? %s) "
+                               "Cannot be the parent of sub-surface.",
+                               parent_id, epc->internal ? "TRUE" : "FALSE");
+        return;
+     }
+
    /* try to create a new subsurface */
    if (!e_comp_wl_subsurface_create(ec, epc, id, surface))
      {