1 From ef55290ab88bb9a640bb0ab7213b6827c7207ee6 Mon Sep 17 00:00:00 2001
2 From: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
3 Date: Fri, 5 Jan 2018 00:01:30 +0900
4 Subject: [PATCH 149/454] vcsm: Support for finding user/vc handle in memory
7 vmcs_sm_{usr,vc}_handle_from_pid_and_address() were failing to find
8 handle if specified user pointer is not exactly the one that the memory
9 locking call returned even if the pointer is in range of map/resource.
10 So fixed the functions to match the range.
12 Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
14 drivers/char/broadcom/vc_sm/vmcs_sm.c | 10 ++++++++--
15 1 file changed, 8 insertions(+), 2 deletions(-)
17 --- a/drivers/char/broadcom/vc_sm/vmcs_sm.c
18 +++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c
19 @@ -276,7 +276,10 @@ static unsigned int vmcs_sm_vc_handle_fr
20 /* Lookup the resource. */
21 if (!list_empty(&sm_state->map_list)) {
22 list_for_each_entry(map, &sm_state->map_list, map_list) {
23 - if (map->res_pid != pid || map->res_addr != addr)
24 + if (map->res_pid != pid)
26 + if (!(map->res_addr <= addr &&
27 + addr < map->res_addr + map->resource->res_size))
30 pr_debug("[%s]: global map %p (pid %u, addr %lx) -> vc-hdl %x (usr-hdl %x)\n",
31 @@ -326,7 +329,10 @@ static unsigned int vmcs_sm_usr_handle_f
32 /* Lookup the resource. */
33 if (!list_empty(&sm_state->map_list)) {
34 list_for_each_entry(map, &sm_state->map_list, map_list) {
35 - if (map->res_pid != pid || map->res_addr != addr)
36 + if (map->res_pid != pid)
38 + if (!(map->res_addr <= addr &&
39 + addr < map->res_addr + map->resource->res_size))
42 pr_debug("[%s]: global map %p (pid %u, addr %lx) -> usr-hdl %x (vc-hdl %x)\n",