Skip to content

Commit 1ab9214

Browse files
Terminus-IMRCpopcornmix
authored andcommitted
vcsm: Support for finding user/vc handle in memory pool
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>
1 parent 4b2da16 commit 1ab9214

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎drivers/char/broadcom/vc_sm/vmcs_sm.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid,
276276
/* Lookup the resource. */
277277
if (!list_empty(&sm_state->map_list)) {
278278
list_for_each_entry(map, &sm_state->map_list, map_list) {
279-
if (map->res_pid != pid || map->res_addr != addr)
279+
if (map->res_pid != pid)
280+
continue;
281+
if (!(map->res_addr <= addr &&
282+
addr < map->res_addr + map->resource->res_size))
280283
continue;
281284

282285
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,
326329
/* Lookup the resource. */
327330
if (!list_empty(&sm_state->map_list)) {
328331
list_for_each_entry(map, &sm_state->map_list, map_list) {
329-
if (map->res_pid != pid || map->res_addr != addr)
332+
if (map->res_pid != pid)
333+
continue;
334+
if (!(map->res_addr <= addr &&
335+
addr < map->res_addr + map->resource->res_size))
330336
continue;
331337

332338
pr_debug("[%s]: global map %p (pid %u, addr %lx) -> usr-hdl %x (vc-hdl %x)\n",

0 commit comments

Comments
 (0)