Skip to content

Commit 97ebbfe

Browse files
hmynenigregkh
authored andcommitted
powerpc/powernv/vas: Release reference to tgid during window close
commit 91cdbb9 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: db1c08a ("powerpc/vas: Take reference to PID and mm for user space windows") Cc: stable@vger.kernel.org # 5.8+ Reported-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Haren Myneni <haren@linux.ibm.com> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/6020fc4d444864fe20f7dcdc5edfe53e67480a1c.camel@linux.ibm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a024e88 commit 97ebbfe

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎arch/powerpc/platforms/powernv/vas-window.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,9 +1093,9 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
10931093
/*
10941094
* Process closes window during exit. In the case of
10951095
* multithread application, the child thread can open
1096-
* window and can exit without closing it. Expects parent
1097-
* thread to use and close the window. So do not need
1098-
* to take pid reference for parent thread.
1096+
* window and can exit without closing it. so takes tgid
1097+
* reference until window closed to make sure tgid is not
1098+
* reused.
10991099
*/
11001100
txwin->tgid = find_get_pid(task_tgid_vnr(current));
11011101
/*
@@ -1339,8 +1339,9 @@ int vas_win_close(struct vas_window *window)
13391339
/* if send window, drop reference to matching receive window */
13401340
if (window->tx_win) {
13411341
if (window->user_win) {
1342-
/* Drop references to pid and mm */
1342+
/* Drop references to pid. tgid and mm */
13431343
put_pid(window->pid);
1344+
put_pid(window->tgid);
13441345
if (window->mm) {
13451346
mm_context_remove_vas_window(window->mm);
13461347
mmdrop(window->mm);

0 commit comments

Comments
 (0)