From 74af06d5cb82cd3e3a10b66747f0176016c13c3d Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Sat, 17 Apr 2021 16:15:35 +0800 Subject: [PATCH] IssueNo:#I3G1Q7 Description:Fix related interface competition issues. Sig:liteos_a Feature or Bugfix:Bugfix Binary Source:No Change-Id: I1198408be9ce577bbf0735e3da53d0834622f429 --- kernel/base/mem/tlsf/los_memory.c | 2 ++ kernel/base/vm/los_vm_map.c | 16 ++++++++++++++-- syscall/syscall_pub.h | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/kernel/base/mem/tlsf/los_memory.c b/kernel/base/mem/tlsf/los_memory.c index 1b2c66c2..82721139 100755 --- a/kernel/base/mem/tlsf/los_memory.c +++ b/kernel/base/mem/tlsf/los_memory.c @@ -1820,6 +1820,8 @@ UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus) return LOS_NOK; } + (VOID)memset_s(poolStatus, sizeof(LOS_MEM_POOL_STATUS), 0, sizeof(LOS_MEM_POOL_STATUS)); + struct OsMemNodeHead *tmpNode = NULL; struct OsMemNodeHead *endNode = NULL; UINT32 intSave; diff --git a/kernel/base/vm/los_vm_map.c b/kernel/base/vm/los_vm_map.c index 77bc1ac8..1ba5a721 100755 --- a/kernel/base/vm/los_vm_map.c +++ b/kernel/base/vm/los_vm_map.c @@ -365,12 +365,24 @@ LosVmMapRegion *OsFindRegion(LosRbTree *regionRbTree, VADDR_T vaddr, size_t len) LosVmMapRegion *LOS_RegionFind(LosVmSpace *vmSpace, VADDR_T addr) { - return OsFindRegion(&vmSpace->regionRbTree, addr, 1); + LosVmMapRegion *region = NULL; + + (VOID)LOS_MuxAcquire(&vmSpace->regionMux); + region = OsFindRegion(&vmSpace->regionRbTree, addr, 1); + (VOID)LOS_MuxRelease(&vmSpace->regionMux); + + return region; } LosVmMapRegion *LOS_RegionRangeFind(LosVmSpace *vmSpace, VADDR_T addr, size_t len) { - return OsFindRegion(&vmSpace->regionRbTree, addr, len); + LosVmMapRegion *region = NULL; + + (VOID)LOS_MuxAcquire(&vmSpace->regionMux); + region = OsFindRegion(&vmSpace->regionRbTree, addr, len); + (VOID)LOS_MuxRelease(&vmSpace->regionMux); + + return region; } VADDR_T OsAllocRange(LosVmSpace *vmSpace, size_t len) diff --git a/syscall/syscall_pub.h b/syscall/syscall_pub.h index 6c9015f0..52993987 100644 --- a/syscall/syscall_pub.h +++ b/syscall/syscall_pub.h @@ -33,6 +33,7 @@ #include #include "los_memory.h" +#include "los_vm_lock.h" #include "los_vm_map.h" #include "user_copy.h" @@ -47,11 +48,15 @@ extern void *DupUserMem(const void *ptr, size_t len, int needCopy); __VA_ARGS__; \ return -get_errno(); \ } \ - if (CheckRegion(OsCurrProcessGet()->vmSpace, (VADDR_T)(UINTPTR)ptr, len) == -1) { \ + LosVmSpace *__aspace = OsCurrProcessGet()->vmSpace; \ + (VOID)LOS_MuxAcquire(&__aspace->regionMux); \ + if (CheckRegion(__aspace, (VADDR_T)(UINTPTR)ptr, len) == -1) { \ + (VOID)LOS_MuxRelease(&__aspace->regionMux); \ set_errno(EFAULT); \ __VA_ARGS__; \ return -get_errno(); \ } \ + (VOID)LOS_MuxRelease(&__aspace->regionMux); \ } \ } while (0)