[CRIU] [PATCH 10/10] seccomp: Fix nits in collect_filter

Cyrill Gorcunov gorcunov at gmail.com
Mon May 7 11:42:50 MSK 2018


 - Fix typo in sizeof() operand
 - Eliminate redundant prctl calls if no PTRACE_SECCOMP_GET_METADATA
   detected

Reported-by: Dmitry Safonov <0x7f454c46 at gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/seccomp.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/criu/seccomp.c b/criu/seccomp.c
index 96a5a62314d8..4a6515c42ec5 100644
--- a/criu/seccomp.c
+++ b/criu/seccomp.c
@@ -151,19 +151,18 @@ static int collect_filter(struct seccomp_entry *entry)
 			}
 		}
 
-		if (!meta)
-			meta = &meta_buf;
-
-		meta->flags = 0;
-		meta->filter_off = i;
-
-		if (ptrace(PTRACE_SECCOMP_GET_METADATA, entry->tid_real, sizeof(meta), meta) < 0) {
-			if (errno == EIO) {
-				meta = NULL;
-			} else {
-				pr_perror("Can't fetch seccomp metadataon tid_real %d pos %zu",
-					  entry->tid_real, i);
-				return -1;
+		if (meta) {
+			meta->filter_off = i;
+
+			if (ptrace(PTRACE_SECCOMP_GET_METADATA, entry->tid_real, sizeof(*meta), meta) < 0) {
+				if (errno == EIO) {
+					/* Old kernel, no METADATA support */
+					meta = NULL;
+				} else {
+					pr_perror("Can't fetch seccomp metadata on tid_real %d pos %zu",
+						  entry->tid_real, i);
+					return -1;
+				}
 			}
 		}
 
-- 
2.14.3



More information about the CRIU mailing list