Thread (21 messages) flat view 21 messages, 3 authors, 2020-03-23

Re: [PATCH V7 08/14] powerpc/vas: Take reference to PID and mm for user space windows

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2020-03-17 04:10:53

Haren Myneni [off-list ref] writes:
Process close windows after its requests are completed. In multi-thread
applications, child can open a window but release FD will not be called
upon its exit. Parent thread will be closing it later upon its exit.
What if the parent exits first?
The parent can also send NX requests with this window and NX can
generate page faults. After kernel handles the page fault, send
signal to process by using PID if CSB address is invalid. Parent
thread will not receive signal since its PID is different from the one
saved in vas_window. So use tgid in case if the task for the pid saved
in window is not running and send signal to its parent.

To prevent reusing the pid until the window closed, take reference to
pid and task mm.
That text is all very dense. Can you please flesh it out and reword it
to clearly spell out what's going on in much more detail.

quoted hunk ↗ jump to hunk
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index a45d81d..7587258 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -1266,8 +1300,17 @@ int vas_win_close(struct vas_window *window)
 	poll_window_castout(window);
 
 	/* if send window, drop reference to matching receive window */
-	if (window->tx_win)
+	if (window->tx_win) {
+		if (window->user_win) {
+			/* Drop references to pid and mm */
+			put_pid(window->pid);
+			if (window->mm) {
+				mmdrop(window->mm);
+				mm_context_remove_copro(window->mm);
That seems backward. Once you drop the reference the mm can be freed
can't it?
+			}
+		}
 		put_rx_win(window->rxwin);
+	}
 
 	vas_window_free(window);
cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help