mirror of
				https://github.com/Ysurac/openmptcprouter.git
				synced 2025-03-09 15:40:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 1ab92143cff8478cddd735b8ddc2d04d69a18ede Mon Sep 17 00:00:00 2001
 | |
| From: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
 | |
| Date: Fri, 5 Jan 2018 00:01:30 +0900
 | |
| Subject: [PATCH 167/277] 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>
 | |
| ---
 | |
|  drivers/char/broadcom/vc_sm/vmcs_sm.c | 10 ++++++++--
 | |
|  1 file changed, 8 insertions(+), 2 deletions(-)
 | |
| 
 | |
| diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c
 | |
| index 53843054d761..abd770566ed3 100644
 | |
| --- a/drivers/char/broadcom/vc_sm/vmcs_sm.c
 | |
| +++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c
 | |
| @@ -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",
 | |
| -- 
 | |
| 2.16.1
 | |
| 
 |