提交 4ec99782 编写于 作者: G Guo Mengqi 提交者: Yang Yingliang

mm: remove sharepool sp_unshare_uva current->mm NULL check

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

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

Remove the unnecessary current->mm NULL check in sp_unshare_uva, and
allow process to unshare kernel mapped addresses in do_exit().
Signed-off-by: NGuo Mengqi <guomengqi3@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 3aa4f0a7
...@@ -3283,16 +3283,11 @@ EXPORT_SYMBOL_GPL(mg_sp_make_share_u2k); ...@@ -3283,16 +3283,11 @@ EXPORT_SYMBOL_GPL(mg_sp_make_share_u2k);
* *
* Procedure of unshare uva must be compatible with: * Procedure of unshare uva must be compatible with:
* *
* 1. DVPP channel destroy procedure: * 1. Process A once was the target of k2u(to group), then it exits.
* do_exit() -> exit_mm() (mm no longer in spg and current->mm == NULL) ->
* exit_task_work() -> task_work_run() -> __fput() -> ... -> vdec_close() ->
* sp_unshare(uva, SPG_ID_DEFAULT)
*
* 2. Process A once was the target of k2u(to group), then it exits.
* Guard worker kthread tries to free this uva and it must succeed, otherwise * Guard worker kthread tries to free this uva and it must succeed, otherwise
* spa of this uva leaks. * spa of this uva leaks.
* *
* This also means we must trust DVPP channel destroy and guard worker code. * This also means we must trust guard worker code.
*/ */
static int sp_unshare_uva(unsigned long uva, unsigned long size) static int sp_unshare_uva(unsigned long uva, unsigned long size)
{ {
...@@ -3339,7 +3334,11 @@ static int sp_unshare_uva(unsigned long uva, unsigned long size) ...@@ -3339,7 +3334,11 @@ static int sp_unshare_uva(unsigned long uva, unsigned long size)
} }
if (spa->type == SPA_TYPE_K2TASK) { if (spa->type == SPA_TYPE_K2TASK) {
if (!current->mm || spa->applier != current->tgid) { /*
* Only allow the original k2task applier process to unshare this uva.
* Kthreads or other processes are not allowed to unshare the uva.
*/
if (spa->applier != current->tgid) {
pr_err_ratelimited("unshare uva(to task) no permission\n"); pr_err_ratelimited("unshare uva(to task) no permission\n");
ret = -EPERM; ret = -EPERM;
goto out_drop_area; goto out_drop_area;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册