提交 6f2f3c03 编写于 作者: H Haren Myneni 提交者: Zheng Zengkai

powerpc/powernv/vas: Release reference to tgid during window close

stable inclusion
from stable-5.10.51
commit 97ebbfe445cd695250ff0ede4fa6e9e5257e2221
bugzilla: 175263 https://gitee.com/openeuler/kernel/issues/I4DT6F

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=97ebbfe445cd695250ff0ede4fa6e9e5257e2221

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

commit 91cdbb95 upstream.

The kernel handles the NX fault by updating CSB or sending
signal to process. In multithread applications, children can
open VAS windows and can exit without closing them. But the
parent can continue to send NX requests with these windows. To
prevent pid reuse, reference will be taken on pid and tgid
when the window is opened and release them during window close.

The current code is not releasing the tgid reference which can
cause pid leak and this patch fixes the issue.

Fixes: db1c08a7 ("powerpc/vas: Take reference to PID and mm for user space windows")
Cc: stable@vger.kernel.org # 5.8+
Reported-by: NNicholas Piggin <npiggin@gmail.com>
Signed-off-by: NHaren Myneni <haren@linux.ibm.com>
Reviewed-by: NNicholas Piggin <npiggin@gmail.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/6020fc4d444864fe20f7dcdc5edfe53e67480a1c.camel@linux.ibm.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 8468baf4
...@@ -1093,9 +1093,9 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop, ...@@ -1093,9 +1093,9 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
/* /*
* Process closes window during exit. In the case of * Process closes window during exit. In the case of
* multithread application, the child thread can open * multithread application, the child thread can open
* window and can exit without closing it. Expects parent * window and can exit without closing it. so takes tgid
* thread to use and close the window. So do not need * reference until window closed to make sure tgid is not
* to take pid reference for parent thread. * reused.
*/ */
txwin->tgid = find_get_pid(task_tgid_vnr(current)); txwin->tgid = find_get_pid(task_tgid_vnr(current));
/* /*
...@@ -1339,8 +1339,9 @@ int vas_win_close(struct vas_window *window) ...@@ -1339,8 +1339,9 @@ int vas_win_close(struct vas_window *window)
/* if send window, drop reference to matching receive window */ /* if send window, drop reference to matching receive window */
if (window->tx_win) { if (window->tx_win) {
if (window->user_win) { if (window->user_win) {
/* Drop references to pid and mm */ /* Drop references to pid. tgid and mm */
put_pid(window->pid); put_pid(window->pid);
put_pid(window->tgid);
if (window->mm) { if (window->mm) {
mm_context_remove_vas_window(window->mm); mm_context_remove_vas_window(window->mm);
mmdrop(window->mm); mmdrop(window->mm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册