Commit 673d1c77 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

seccomp: Fix nits in collect_filter

- Fix typo in sizeof() operand
 - Eliminate redundant prctl calls if no PTRACE_SECCOMP_GET_METADATA
   detected
Reported-by: 's avatarDmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent b4451351
...@@ -151,19 +151,18 @@ static int collect_filter(struct seccomp_entry *entry) ...@@ -151,19 +151,18 @@ static int collect_filter(struct seccomp_entry *entry)
} }
} }
if (!meta) if (meta) {
meta = &meta_buf; meta->filter_off = i;
meta->flags = 0; if (ptrace(PTRACE_SECCOMP_GET_METADATA, entry->tid_real, sizeof(*meta), meta) < 0) {
meta->filter_off = i; if (errno == EIO) {
/* Old kernel, no METADATA support */
if (ptrace(PTRACE_SECCOMP_GET_METADATA, entry->tid_real, sizeof(meta), meta) < 0) { meta = NULL;
if (errno == EIO) { } else {
meta = NULL; pr_perror("Can't fetch seccomp metadata on tid_real %d pos %zu",
} else { entry->tid_real, i);
pr_perror("Can't fetch seccomp metadataon tid_real %d pos %zu", return -1;
entry->tid_real, i); }
return -1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment