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

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