}
-static int seccomp_start(uint32_t seccomp_opts)
+static int seccomp_start(uint32_t seccomp_opts, Error **errp)
{
- int rc = 0;
+ int rc = -1;
unsigned int i = 0;
scmp_filter_ctx ctx;
ctx = seccomp_init(SCMP_ACT_ALLOW);
if (ctx == NULL) {
- rc = -1;
+ error_setg(errp, "failed to initialize seccomp context");
goto seccomp_return;
}
rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_TSYNC, 1);
if (rc != 0) {
+ error_setg_errno(errp, -rc,
+ "failed to set seccomp thread synchronization");
goto seccomp_return;
}
rc = seccomp_rule_add_array(ctx, action, blacklist[i].num,
blacklist[i].narg, blacklist[i].arg_cmp);
if (rc < 0) {
+ error_setg_errno(errp, -rc,
+ "failed to add seccomp blacklist rules");
goto seccomp_return;
}
}
rc = seccomp_load(ctx);
+ if (rc < 0) {
+ error_setg_errno(errp, -rc,
+ "failed to load seccomp syscall filter in kernel");
+ }
seccomp_return:
seccomp_release(ctx);
- return rc;
+ return rc < 0 ? -1 : 0;
}
#ifdef CONFIG_SECCOMP
}
}
- if (seccomp_start(seccomp_opts) < 0) {
- error_setg(errp, "failed to install seccomp syscall filter "
- "in the kernel");
+ if (seccomp_start(seccomp_opts, errp) < 0) {
return -1;
}
}