OSDN Git Service

powerpc/vas: Take reference to PID and mm for user space windows
authorHaren Myneni <haren@linux.ibm.com>
Thu, 16 Apr 2020 06:02:16 +0000 (23:02 -0700)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 20 Apr 2020 06:53:00 +0000 (16:53 +1000)
commitdb1c08a7406351673c52594f5c8a65829baf5bf6
treed809ccccd82d3e1e0dfafb96de4c772232ef44c1
parent8b8a73dc7919489b54ccd2772b2948088d3dbe6d
powerpc/vas: Take reference to PID and mm for user space windows

When process opens a window, its pid and tgid will be saved in the
vas_window struct. This window will be closed when the process exits.
The kernel handles NX faults by updating CSB or send SEGV signal to pid
of the process if the userspace csb addr is invalid.

In multi-thread applications, a window can be opened by a child thread,
but it will not be closed when this thread exits. It is expected that
the parent will clean up all resources including NX windows opened by
child threads. A child thread can send NX requests using this window
and could be killed before completion is reported. If the pid assigned
to this thread is reused while requests are pending, a failure SEGV
would be directed to the wrong place.

To prevent reusing the pid, take references to pid and mm when the window
is opened and release them when when the window is closed. Then if child
thread is not running, SEGV signal will be sent to thread group leader
(tgid).

Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1587016936.2275.1057.camel@hbabu-laptop
arch/powerpc/platforms/powernv/vas-debug.c
arch/powerpc/platforms/powernv/vas-window.c
arch/powerpc/platforms/powernv/vas.h