<html><body><p><tt><font size="2">"Linuxppc-dev" <linuxppc-dev-bounces+hbabu=us.ibm.com@lists.ozlabs.org> wrote on 11/27/2019 12:46:09 AM:<br>> >  <br>> > +static void notify_process(pid_t pid, u64 fault_addr)<br>> > +{<br>> > +   int rc;<br>> > +   struct kernel_siginfo info;<br>> > +<br>> > +   memset(&info, 0, sizeof(info));<br>> > +<br>> > +   info.si_signo = SIGSEGV;<br>> > +   info.si_errno = EFAULT;<br>> > +   info.si_code = SEGV_MAPERR;<br>> > +<br>> > +   info.si_addr = (void *)fault_addr;<br>> > +   rcu_read_lock();<br>> > +   rc = kill_pid_info(SIGSEGV, &info, find_vpid(pid));<br>> > +   rcu_read_unlock();<br>> > +<br>> > +   pr_devel("%s(): pid %d kill_proc_info() rc %d\n", __func__, pid, rc);<br>> > +}<br>> <br>> Shouldn't this use force_sig_fault_to_task instead?<br>> <br>> > +   /*<br>> > +    * User space passed invalid CSB address, Notify process with<br>> > +    * SEGV signal.<br>> > +    */<br>> > +   tsk = get_pid_task(window->pid, PIDTYPE_PID);<br>> > +   /*<br>> > +    * Send window will be closed after processing all NX requests<br>> > +    * and process exits after closing all windows. In multi-thread<br>> > +    * applications, thread may not exists, but does not close FD<br>> > +    * (means send window) upon exit. Parent thread (tgid) can use<br>> > +    * and close the window later.<br>> > +    */<br>> > +   if (tsk) {<br>> > +      if (tsk->flags & PF_EXITING)<br>> > +         task_exit = 1;<br>> > +      put_task_struct(tsk);<br>> > +      pid = </font></tt><tt><font size="2">vas_window_pid</font></tt><tt><font size="2">(window);<br>> <br>> The pid is later used for sending the signal again, why not keep the<br>> reference?</font></tt><br><br><tt><font size="2">Sorry, Not dropping the PID reference here, Happens only when window closed. If the task for this PID is not available, looking for tgid in the case of multi-thread process.<br>> <br>> > +   } else {<br>> > +      pid = vas_window_tgid(window);<br>> > +<br>> > +      rcu_read_lock();<br>> > +      tsk = find_task_by_vpid(pid);<br>> > +      if (!tsk) {<br>> > +         rcu_read_unlock();<br>> > +         return;<br>> > +      }<br>> > +      if (tsk->flags & PF_EXITING)<br>> > +         task_exit = 1;<br>> > +      rcu_read_unlock();<br>> <br>> Why does this not need a reference to the task, but the other one does?</font></tt><br><br><tt><font size="2">Window is opened with open() and ioctl(fd), will be closed either by close(fd) explicitly or release FD during process exit. </font></tt><br><br><tt><font size="2">Process closes all open windows when it exits. So we do not need to keep the reference for this case. In multi-thread case, child thread can open a window, but it does not release FD when it exits. Parent thread (tgid) can continue use this window and closes it upon its exit. So taking reference to PID in case if this pid is assigned to child thread to make sure its pid is not reused until window is closed. </font></tt><br><br><tt><font size="2">We are taking pid reference during window open and releases it when closing the window. </font></tt><br><br><tt><font size="2">Thanks</font></tt><br><tt><font size="2">Haren </font></tt><br><br><br><tt><font size="2"><br>> <br></font></tt><BR>
</body></html>