]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
vcsm: Support for finding user/vc handle in memory pool
authorSugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
Thu, 4 Jan 2018 15:01:30 +0000 (00:01 +0900)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 15 Aug 2018 17:23:07 +0000 (19:23 +0200)
vmcs_sm_{usr,vc}_handle_from_pid_and_address() were failing to find
handle if specified user pointer is not exactly the one that the memory
locking call returned even if the pointer is in range of map/resource.
So fixed the functions to match the range.

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
(cherry picked from commit 662ef06002e3d43ad76671bb9598cd61e265bef5
https://github.com/raspberrypi/linux raspi/rpi-4.15.y)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/char/broadcom/vc_sm/vmcs_sm.c

index 53843054d7617716761b74d8a3d91551b91ffb75..abd770566ed30102b95a01cec6a3825b23afcd9d 100644 (file)
@@ -276,7 +276,10 @@ static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid,
        /* Lookup the resource. */
        if (!list_empty(&sm_state->map_list)) {
                list_for_each_entry(map, &sm_state->map_list, map_list) {
-                       if (map->res_pid != pid || map->res_addr != addr)
+                       if (map->res_pid != pid)
+                               continue;
+                       if (!(map->res_addr <= addr &&
+                                               addr < map->res_addr + map->resource->res_size))
                                continue;
 
                        pr_debug("[%s]: global map %p (pid %u, addr %lx) -> vc-hdl %x (usr-hdl %x)\n",
@@ -326,7 +329,10 @@ static unsigned int vmcs_sm_usr_handle_from_pid_and_address(unsigned int pid,
        /* Lookup the resource. */
        if (!list_empty(&sm_state->map_list)) {
                list_for_each_entry(map, &sm_state->map_list, map_list) {
-                       if (map->res_pid != pid || map->res_addr != addr)
+                       if (map->res_pid != pid)
+                               continue;
+                       if (!(map->res_addr <= addr &&
+                                               addr < map->res_addr + map->resource->res_size))
                                continue;
 
                        pr_debug("[%s]: global map %p (pid %u, addr %lx) -> usr-hdl %x (vc-hdl %x)\n",