提交 ca41a70d 编写于 作者: O openharmony_ci 提交者: Gitee

!132 VfsJffs2Lookup中VfsHashGet获取的vnode未判断data字段的有效性

Merge pull request !132 from zhangfanfan2/jffs2
...@@ -574,12 +574,8 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr) ...@@ -574,12 +574,8 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
PrintExcInfo("User mode exception ends unscheduled!\n"); PrintExcInfo("User mode exception ends unscheduled!\n");
} }
/* /* this function is used to validate fp or validate the checking range start and end. */
* This function is used to determine whether the first input parameter is a valid virtual address. STATIC INLINE BOOL IsValidFP(UINTPTR regFP, UINTPTR start, UINTPTR end, vaddr_t *vaddr)
* If it is, it is converted into a kernel virtual address and the converted kernel virtual address
* is used as an output parameter.
*/
STATIC INLINE BOOL IsValidVaddr(UINTPTR regFP, UINTPTR start, UINTPTR end, vaddr_t *vaddr)
{ {
VADDR_T kvaddr = regFP; VADDR_T kvaddr = regFP;
...@@ -622,7 +618,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end ...@@ -622,7 +618,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
taskCB = OsCurrTaskGet(); taskCB = OsCurrTaskGet();
stackStart = taskCB->userMapBase; stackStart = taskCB->userMapBase;
stackEnd = taskCB->userMapBase + taskCB->userMapSize; stackEnd = taskCB->userMapBase + taskCB->userMapSize;
if (IsValidVaddr(regFP, stackStart, stackEnd, &kvaddr) == TRUE) { if (IsValidFP(regFP, stackStart, stackEnd, &kvaddr) == TRUE) {
found = TRUE; found = TRUE;
goto FOUND; goto FOUND;
} }
...@@ -638,7 +634,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end ...@@ -638,7 +634,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
stackStart = taskCB->topOfStack; stackStart = taskCB->topOfStack;
stackEnd = taskCB->topOfStack + taskCB->stackSize; stackEnd = taskCB->topOfStack + taskCB->stackSize;
if (IsValidVaddr(regFP, stackStart, stackEnd, &kvaddr) == TRUE) { if (IsValidFP(regFP, stackStart, stackEnd, &kvaddr) == TRUE) {
found = TRUE; found = TRUE;
goto FOUND; goto FOUND;
} }
...@@ -649,7 +645,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end ...@@ -649,7 +645,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
stack = &g_excStack[index]; stack = &g_excStack[index];
stackStart = (UINTPTR)stack->stackTop; stackStart = (UINTPTR)stack->stackTop;
stackEnd = stackStart + LOSCFG_KERNEL_CORE_NUM * stack->stackSize; stackEnd = stackStart + LOSCFG_KERNEL_CORE_NUM * stack->stackSize;
if (IsValidVaddr(regFP, stackStart, stackEnd, &kvaddr) == TRUE) { if (IsValidFP(regFP, stackStart, stackEnd, &kvaddr) == TRUE) {
found = TRUE; found = TRUE;
goto FOUND; goto FOUND;
} }
...@@ -685,23 +681,23 @@ VOID BackTraceSub(UINTPTR regFP) ...@@ -685,23 +681,23 @@ VOID BackTraceSub(UINTPTR regFP)
* will still be stored and updated. In that case we needs to find the right position of frame pointer. * will still be stored and updated. In that case we needs to find the right position of frame pointer.
*/ */
tmpFP = *(UINTPTR *)(UINTPTR)kvaddr; tmpFP = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidVaddr(tmpFP, stackStart, stackEnd, NULL) == TRUE) { if (IsValidFP(tmpFP, stackStart, stackEnd, NULL) == TRUE) {
backFP = tmpFP; backFP = tmpFP;
PrintExcInfo("traceback fp fixed, trace using fp = 0x%x\n", backFP); PrintExcInfo("traceback fp fixed, trace using fp = 0x%x\n", backFP);
} }
while (IsValidVaddr(backFP, stackStart, stackEnd, &kvaddr) == TRUE) { while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) {
tmpFP = backFP; tmpFP = backFP;
#ifdef LOSCFG_COMPILER_CLANG_LLVM #ifdef LOSCFG_COMPILER_CLANG_LLVM
backFP = *(UINTPTR *)(UINTPTR)kvaddr; backFP = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidVaddr(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) { if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE); PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
return; return;
} }
backLR = *(UINTPTR *)(UINTPTR)kvaddr; backLR = *(UINTPTR *)(UINTPTR)kvaddr;
#else #else
backLR = *(UINTPTR *)(UINTPTR)kvaddr; backLR = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidVaddr(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) { if (IsValidFP(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE); PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
return; return;
} }
......
...@@ -202,6 +202,9 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct ...@@ -202,6 +202,9 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
(void)VfsHashGet(parentVnode->originMount, node->i_ino, &newVnode, NULL, NULL); (void)VfsHashGet(parentVnode->originMount, node->i_ino, &newVnode, NULL, NULL);
LOS_MuxUnlock(&g_jffs2FsLock); LOS_MuxUnlock(&g_jffs2FsLock);
if (newVnode) { if (newVnode) {
if (newVnode->data == NULL) {
LOS_Panic("#####VfsHashGet error#####\n");
}
*ppVnode = newVnode; *ppVnode = newVnode;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册