提交 ed147d80 编写于 作者: W Wang Wensheng 提交者: Yang Yingliang

share_pool: Check tsk->mm before use it

ascend inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI
CVE: NA

-------------------

The user could give a pid of daemon process when add task to group. That
daemon process has no mm_struct so we should check it before use.
Signed-off-by: NWang Wensheng <wangwensheng4@huawei.com>
Reviewed-by: NDing Tianhong <dingtianhong@huawei.com>
Reviewed-by: NTang Yizhou <tangyizhou@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 fcbf90cf
...@@ -549,8 +549,6 @@ int sp_group_add_task(int pid, int spg_id) ...@@ -549,8 +549,6 @@ int sp_group_add_task(int pid, int spg_id)
tsk = find_task_by_vpid(pid); tsk = find_task_by_vpid(pid);
if (!tsk || (tsk->flags & PF_EXITING)) if (!tsk || (tsk->flags & PF_EXITING))
ret = -ESRCH; ret = -ESRCH;
else if (tsk->mm->sp_group) /* if it's already in a sp_group */
ret = -EEXIST;
else else
get_task_struct(tsk); get_task_struct(tsk);
...@@ -560,6 +558,11 @@ int sp_group_add_task(int pid, int spg_id) ...@@ -560,6 +558,11 @@ int sp_group_add_task(int pid, int spg_id)
goto out_unlock; goto out_unlock;
} }
if (!tsk->mm || tsk->mm->sp_group) { /* if it's already in a sp_group */
ret = -EEXIST;
goto out_unlock;
}
spg = find_or_alloc_sp_group(spg_id); spg = find_or_alloc_sp_group(spg_id);
if (IS_ERR(spg)) { if (IS_ERR(spg)) {
ret = PTR_ERR(spg); ret = PTR_ERR(spg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册