From: Qingshuang Fu <[email protected]>

sig_handler() passes its arguments to kill() in the wrong order: it
sends signal number child_pid to PID SIGTERM (15) instead of sending
SIGTERM to the client process.  The call therefore always fails
(a pid is virtually never a valid signal number) and the client is
never notified: when only the server process receives SIGTERM, the
client keeps running its infinite connect loop as an orphan process.

Swap the arguments so that the server forwards SIGTERM to the client.
Also guard the call with child_pid > 0: the client inherits the
handler and sees child_pid == 0, and a plain argument swap would make
it call kill(0, SIGTERM), signaling the whole process group (including
the invoking shell) instead of exiting quietly.

Fixes: af8c8a450bf4 ("selftests: net: Add FIN_ACK processing order related 
latency spike test")
Signed-off-by: Qingshuang Fu <[email protected]>
---
 tools/testing/selftests/net/fin_ack_lat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/fin_ack_lat.c 
b/tools/testing/selftests/net/fin_ack_lat.c
index 70187494b57a..f985e01354b4 100644
--- a/tools/testing/selftests/net/fin_ack_lat.c
+++ b/tools/testing/selftests/net/fin_ack_lat.c
@@ -103,7 +103,8 @@ static void server(int sock, struct sockaddr_in address)
 
 static void sig_handler(int signum)
 {
-       kill(SIGTERM, child_pid);
+       if (child_pid > 0)
+               kill(child_pid, SIGTERM);
        exit(0);
 }
 

base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
-- 
2.25.1


Reply via email to