Blame SOURCES/0036-syscall.c-avoid-infinite-loop-in-subcalls-parsing.patch

7a62b9
From 522ad3a0e73148dadd2480cd9cec84d9112b2e57 Mon Sep 17 00:00:00 2001
7a62b9
From: Eugene Syromyatnikov <evgsyr@gmail.com>
7a62b9
Date: Tue, 4 Sep 2018 14:48:13 +0200
7a62b9
Subject: [PATCH] syscall.c: avoid infinite loop in subcalls parsing
7a62b9
7a62b9
clang complains about it, so it might be a good reason to refactor it
7a62b9
into something more linear.
7a62b9
7a62b9
* syscall.c (syscall_entering_decode): Put syscall subcall decoding
7a62b9
before ipc/socket subcall decoding, remove the loop.
7a62b9
---
7a62b9
 syscall.c | 19 ++++++-------------
7a62b9
 1 file changed, 6 insertions(+), 13 deletions(-)
7a62b9
7a62b9
diff --git a/syscall.c b/syscall.c
7a62b9
index bae7343..a67d744 100644
7a62b9
--- a/syscall.c
7a62b9
+++ b/syscall.c
7a62b9
@@ -579,11 +579,13 @@ syscall_entering_decode(struct tcb *tcp)
7a62b9
 		return res;
7a62b9
 	}
7a62b9
 
7a62b9
+# ifdef SYS_syscall_subcall
7a62b9
+	if (tcp_sysent(tcp)->sen == SEN_syscall)
7a62b9
+		decode_syscall_subcall(tcp);
7a62b9
+# endif
7a62b9
 #if defined SYS_ipc_subcall	\
7a62b9
- || defined SYS_socket_subcall	\
7a62b9
- || defined SYS_syscall_subcall
7a62b9
-	for (;;) {
7a62b9
-		switch (tcp_sysent(tcp)->sen) {
7a62b9
+ || defined SYS_socket_subcall
7a62b9
+	switch (tcp_sysent(tcp)->sen) {
7a62b9
 # ifdef SYS_ipc_subcall
7a62b9
 		case SEN_ipc:
7a62b9
 			decode_ipc_subcall(tcp);
7a62b9
@@ -594,15 +596,6 @@ syscall_entering_decode(struct tcb *tcp)
7a62b9
 			decode_socket_subcall(tcp);
7a62b9
 			break;
7a62b9
 # endif
7a62b9
-# ifdef SYS_syscall_subcall
7a62b9
-		case SEN_syscall:
7a62b9
-			decode_syscall_subcall(tcp);
7a62b9
-			if (tcp_sysent(tcp)->sen != SEN_syscall)
7a62b9
-				continue;
7a62b9
-			break;
7a62b9
-# endif
7a62b9
-		}
7a62b9
-		break;
7a62b9
 	}
7a62b9
 #endif
7a62b9
 
7a62b9
-- 
7a62b9
2.1.4
7a62b9