!496 修复mprotect修改地址区间的权限后,相应的区间名丢失问题
Merge pull request !496 from Harylee/mem
This commit is contained in:
commit
007c75eb18
|
@ -257,7 +257,28 @@ REGION_ALLOC_FAILED:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int LOS_DoMprotect(VADDR_T vaddr, size_t len, unsigned long prot)
|
||||
STATIC UINT32 OsInheritOldRegionName(UINT32 oldRegionFlags)
|
||||
{
|
||||
UINT32 vmFlags = 0;
|
||||
|
||||
if (oldRegionFlags & VM_MAP_REGION_FLAG_HEAP) {
|
||||
vmFlags |= VM_MAP_REGION_FLAG_HEAP;
|
||||
} else if (oldRegionFlags & VM_MAP_REGION_FLAG_STACK) {
|
||||
vmFlags |= VM_MAP_REGION_FLAG_STACK;
|
||||
} else if (oldRegionFlags & VM_MAP_REGION_FLAG_TEXT) {
|
||||
vmFlags |= VM_MAP_REGION_FLAG_TEXT;
|
||||
} else if (oldRegionFlags & VM_MAP_REGION_FLAG_VDSO) {
|
||||
vmFlags |= VM_MAP_REGION_FLAG_VDSO;
|
||||
} else if (oldRegionFlags & VM_MAP_REGION_FLAG_MMAP) {
|
||||
vmFlags |= VM_MAP_REGION_FLAG_MMAP;
|
||||
} else if (oldRegionFlags & VM_MAP_REGION_FLAG_SHM) {
|
||||
vmFlags |= VM_MAP_REGION_FLAG_SHM;
|
||||
}
|
||||
|
||||
return vmFlags;
|
||||
}
|
||||
|
||||
INT32 LOS_DoMprotect(VADDR_T vaddr, size_t len, unsigned long prot)
|
||||
{
|
||||
LosVmSpace *space = OsCurrProcessGet()->vmSpace;
|
||||
LosVmMapRegion *region = NULL;
|
||||
|
@ -291,7 +312,7 @@ int LOS_DoMprotect(VADDR_T vaddr, size_t len, unsigned long prot)
|
|||
|
||||
len = LOS_Align(len, PAGE_SIZE);
|
||||
/* can't operation cross region */
|
||||
if (region->range.base + region->range.size < vaddr + len) {
|
||||
if ((region->range.base + region->range.size) < (vaddr + len)) {
|
||||
ret = -EINVAL;
|
||||
goto OUT_MPROTECT;
|
||||
}
|
||||
|
@ -303,6 +324,7 @@ int LOS_DoMprotect(VADDR_T vaddr, size_t len, unsigned long prot)
|
|||
|
||||
vmFlags = OsCvtProtFlagsToRegionFlags(prot, 0);
|
||||
vmFlags |= (region->regionFlags & VM_MAP_REGION_FLAG_SHARED) ? VM_MAP_REGION_FLAG_SHARED : 0;
|
||||
vmFlags |= OsInheritOldRegionName(region->regionFlags);
|
||||
region = LOS_RegionFind(space, vaddr);
|
||||
if (region == NULL) {
|
||||
ret = -ENOMEM;
|
||||
|
|
Loading…
Reference in New Issue