qemu-seccomp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. * QEMU seccomp mode 2 support with libseccomp
  3. *
  4. * Copyright IBM, Corp. 2012
  5. *
  6. * Authors:
  7. * Eduardo Otubo <eotubo@br.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2. See
  10. * the COPYING file in the top-level directory.
  11. *
  12. * Contributions after 2012-01-13 are licensed under the terms of the
  13. * GNU GPL, version 2 or (at your option) any later version.
  14. */
  15. #include "qemu/osdep.h"
  16. #include "qapi/error.h"
  17. #include "qemu/config-file.h"
  18. #include "qemu/option.h"
  19. #include "qemu/module.h"
  20. #include <sys/prctl.h>
  21. #include <seccomp.h>
  22. #include "system/seccomp.h"
  23. #include <linux/seccomp.h>
  24. /* For some architectures (notably ARM) cacheflush is not supported until
  25. * libseccomp 2.2.3, but configure enforces that we are using a more recent
  26. * version on those hosts, so it is OK for this check to be less strict.
  27. */
  28. #if SCMP_VER_MAJOR >= 3
  29. #define HAVE_CACHEFLUSH
  30. #elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR >= 2
  31. #define HAVE_CACHEFLUSH
  32. #endif
  33. struct QemuSeccompSyscall {
  34. int32_t num;
  35. uint8_t set;
  36. uint8_t narg;
  37. const struct scmp_arg_cmp *arg_cmp;
  38. uint32_t action;
  39. };
  40. const struct scmp_arg_cmp sched_setscheduler_arg[] = {
  41. /* was SCMP_A1(SCMP_CMP_NE, SCHED_IDLE), but expanded due to GCC 4.x bug */
  42. { .arg = 1, .op = SCMP_CMP_NE, .datum_a = SCHED_IDLE }
  43. };
  44. /*
  45. * See 'NOTES' in 'man 2 clone' - s390 has 'flags' in
  46. * different position to other architectures
  47. */
  48. #if defined(HOST_S390X) || defined(HOST_S390)
  49. #define CLONE_FLAGS_ARG 1
  50. #else
  51. #define CLONE_FLAGS_ARG 0
  52. #endif
  53. #ifndef CLONE_PIDFD
  54. # define CLONE_PIDFD 0x00001000
  55. #endif
  56. #define REQUIRE_CLONE_FLAG(flag) \
  57. const struct scmp_arg_cmp clone_arg ## flag[] = { \
  58. { .arg = CLONE_FLAGS_ARG, \
  59. .op = SCMP_CMP_MASKED_EQ, \
  60. .datum_a = flag, .datum_b = 0 } }
  61. #define FORBID_CLONE_FLAG(flag) \
  62. const struct scmp_arg_cmp clone_arg ## flag[] = { \
  63. { .arg = CLONE_FLAGS_ARG, \
  64. .op = SCMP_CMP_MASKED_EQ, \
  65. .datum_a = flag, .datum_b = flag } }
  66. #define RULE_CLONE_FLAG(flag) \
  67. { SCMP_SYS(clone), QEMU_SECCOMP_SET_SPAWN, \
  68. ARRAY_SIZE(clone_arg ## flag), clone_arg ## flag, SCMP_ACT_ERRNO(EPERM) }
  69. /* If no CLONE_* flags are set, except CSIGNAL, deny */
  70. const struct scmp_arg_cmp clone_arg_none[] = {
  71. { .arg = CLONE_FLAGS_ARG,
  72. .op = SCMP_CMP_MASKED_EQ,
  73. .datum_a = ~(CSIGNAL), .datum_b = 0 }
  74. };
  75. /*
  76. * pthread_create should always set all of these.
  77. */
  78. REQUIRE_CLONE_FLAG(CLONE_VM);
  79. REQUIRE_CLONE_FLAG(CLONE_FS);
  80. REQUIRE_CLONE_FLAG(CLONE_FILES);
  81. REQUIRE_CLONE_FLAG(CLONE_SIGHAND);
  82. REQUIRE_CLONE_FLAG(CLONE_THREAD);
  83. REQUIRE_CLONE_FLAG(CLONE_SYSVSEM);
  84. REQUIRE_CLONE_FLAG(CLONE_SETTLS);
  85. REQUIRE_CLONE_FLAG(CLONE_PARENT_SETTID);
  86. REQUIRE_CLONE_FLAG(CLONE_CHILD_CLEARTID);
  87. /*
  88. * Musl sets this in pthread_create too, but it is
  89. * obsolete and harmless since its behaviour is
  90. * subsumed under CLONE_THREAD
  91. */
  92. /*REQUIRE_CLONE_FLAG(CLONE_DETACHED);*/
  93. /*
  94. * These all indicate an attempt to spawn a process
  95. * instead of a thread, or other undesirable scenarios
  96. */
  97. FORBID_CLONE_FLAG(CLONE_PIDFD);
  98. FORBID_CLONE_FLAG(CLONE_PTRACE);
  99. FORBID_CLONE_FLAG(CLONE_VFORK);
  100. FORBID_CLONE_FLAG(CLONE_PARENT);
  101. FORBID_CLONE_FLAG(CLONE_NEWNS);
  102. FORBID_CLONE_FLAG(CLONE_UNTRACED);
  103. FORBID_CLONE_FLAG(CLONE_NEWCGROUP);
  104. FORBID_CLONE_FLAG(CLONE_NEWUTS);
  105. FORBID_CLONE_FLAG(CLONE_NEWIPC);
  106. FORBID_CLONE_FLAG(CLONE_NEWUSER);
  107. FORBID_CLONE_FLAG(CLONE_NEWPID);
  108. FORBID_CLONE_FLAG(CLONE_NEWNET);
  109. FORBID_CLONE_FLAG(CLONE_IO);
  110. static const struct QemuSeccompSyscall denylist[] = {
  111. /* default set of syscalls that should get blocked */
  112. { SCMP_SYS(reboot), QEMU_SECCOMP_SET_DEFAULT,
  113. 0, NULL, SCMP_ACT_TRAP },
  114. { SCMP_SYS(swapon), QEMU_SECCOMP_SET_DEFAULT,
  115. 0, NULL, SCMP_ACT_TRAP },
  116. { SCMP_SYS(swapoff), QEMU_SECCOMP_SET_DEFAULT,
  117. 0, NULL, SCMP_ACT_TRAP },
  118. { SCMP_SYS(syslog), QEMU_SECCOMP_SET_DEFAULT,
  119. 0, NULL, SCMP_ACT_TRAP },
  120. { SCMP_SYS(mount), QEMU_SECCOMP_SET_DEFAULT,
  121. 0, NULL, SCMP_ACT_TRAP },
  122. { SCMP_SYS(umount), QEMU_SECCOMP_SET_DEFAULT,
  123. 0, NULL, SCMP_ACT_TRAP },
  124. { SCMP_SYS(kexec_load), QEMU_SECCOMP_SET_DEFAULT,
  125. 0, NULL, SCMP_ACT_TRAP },
  126. { SCMP_SYS(afs_syscall), QEMU_SECCOMP_SET_DEFAULT,
  127. 0, NULL, SCMP_ACT_TRAP },
  128. { SCMP_SYS(break), QEMU_SECCOMP_SET_DEFAULT,
  129. 0, NULL, SCMP_ACT_TRAP },
  130. { SCMP_SYS(ftime), QEMU_SECCOMP_SET_DEFAULT,
  131. 0, NULL, SCMP_ACT_TRAP },
  132. { SCMP_SYS(getpmsg), QEMU_SECCOMP_SET_DEFAULT,
  133. 0, NULL, SCMP_ACT_TRAP },
  134. { SCMP_SYS(gtty), QEMU_SECCOMP_SET_DEFAULT,
  135. 0, NULL, SCMP_ACT_TRAP },
  136. { SCMP_SYS(lock), QEMU_SECCOMP_SET_DEFAULT,
  137. 0, NULL, SCMP_ACT_TRAP },
  138. { SCMP_SYS(mpx), QEMU_SECCOMP_SET_DEFAULT,
  139. 0, NULL, SCMP_ACT_TRAP },
  140. { SCMP_SYS(prof), QEMU_SECCOMP_SET_DEFAULT,
  141. 0, NULL, SCMP_ACT_TRAP },
  142. { SCMP_SYS(profil), QEMU_SECCOMP_SET_DEFAULT,
  143. 0, NULL, SCMP_ACT_TRAP },
  144. { SCMP_SYS(putpmsg), QEMU_SECCOMP_SET_DEFAULT,
  145. 0, NULL, SCMP_ACT_TRAP },
  146. { SCMP_SYS(security), QEMU_SECCOMP_SET_DEFAULT,
  147. 0, NULL, SCMP_ACT_TRAP },
  148. { SCMP_SYS(stty), QEMU_SECCOMP_SET_DEFAULT,
  149. 0, NULL, SCMP_ACT_TRAP },
  150. { SCMP_SYS(tuxcall), QEMU_SECCOMP_SET_DEFAULT,
  151. 0, NULL, SCMP_ACT_TRAP },
  152. { SCMP_SYS(ulimit), QEMU_SECCOMP_SET_DEFAULT,
  153. 0, NULL, SCMP_ACT_TRAP },
  154. { SCMP_SYS(vserver), QEMU_SECCOMP_SET_DEFAULT,
  155. 0, NULL, SCMP_ACT_TRAP },
  156. /* obsolete */
  157. { SCMP_SYS(readdir), QEMU_SECCOMP_SET_OBSOLETE,
  158. 0, NULL, SCMP_ACT_TRAP },
  159. { SCMP_SYS(_sysctl), QEMU_SECCOMP_SET_OBSOLETE,
  160. 0, NULL, SCMP_ACT_TRAP },
  161. { SCMP_SYS(bdflush), QEMU_SECCOMP_SET_OBSOLETE,
  162. 0, NULL, SCMP_ACT_TRAP },
  163. { SCMP_SYS(create_module), QEMU_SECCOMP_SET_OBSOLETE,
  164. 0, NULL, SCMP_ACT_TRAP },
  165. { SCMP_SYS(get_kernel_syms), QEMU_SECCOMP_SET_OBSOLETE,
  166. 0, NULL, SCMP_ACT_TRAP },
  167. { SCMP_SYS(query_module), QEMU_SECCOMP_SET_OBSOLETE,
  168. 0, NULL, SCMP_ACT_TRAP },
  169. { SCMP_SYS(sgetmask), QEMU_SECCOMP_SET_OBSOLETE,
  170. 0, NULL, SCMP_ACT_TRAP },
  171. { SCMP_SYS(ssetmask), QEMU_SECCOMP_SET_OBSOLETE,
  172. 0, NULL, SCMP_ACT_TRAP },
  173. { SCMP_SYS(sysfs), QEMU_SECCOMP_SET_OBSOLETE,
  174. 0, NULL, SCMP_ACT_TRAP },
  175. { SCMP_SYS(uselib), QEMU_SECCOMP_SET_OBSOLETE,
  176. 0, NULL, SCMP_ACT_TRAP },
  177. { SCMP_SYS(ustat), QEMU_SECCOMP_SET_OBSOLETE,
  178. 0, NULL, SCMP_ACT_TRAP },
  179. /* privileged */
  180. { SCMP_SYS(setuid), QEMU_SECCOMP_SET_PRIVILEGED,
  181. 0, NULL, SCMP_ACT_TRAP },
  182. { SCMP_SYS(setgid), QEMU_SECCOMP_SET_PRIVILEGED,
  183. 0, NULL, SCMP_ACT_TRAP },
  184. { SCMP_SYS(setpgid), QEMU_SECCOMP_SET_PRIVILEGED,
  185. 0, NULL, SCMP_ACT_TRAP },
  186. { SCMP_SYS(setsid), QEMU_SECCOMP_SET_PRIVILEGED,
  187. 0, NULL, SCMP_ACT_TRAP },
  188. { SCMP_SYS(setreuid), QEMU_SECCOMP_SET_PRIVILEGED,
  189. 0, NULL, SCMP_ACT_TRAP },
  190. { SCMP_SYS(setregid), QEMU_SECCOMP_SET_PRIVILEGED,
  191. 0, NULL, SCMP_ACT_TRAP },
  192. { SCMP_SYS(setresuid), QEMU_SECCOMP_SET_PRIVILEGED,
  193. 0, NULL, SCMP_ACT_TRAP },
  194. { SCMP_SYS(setresgid), QEMU_SECCOMP_SET_PRIVILEGED,
  195. 0, NULL, SCMP_ACT_TRAP },
  196. { SCMP_SYS(setfsuid), QEMU_SECCOMP_SET_PRIVILEGED,
  197. 0, NULL, SCMP_ACT_TRAP },
  198. { SCMP_SYS(setfsgid), QEMU_SECCOMP_SET_PRIVILEGED,
  199. 0, NULL, SCMP_ACT_TRAP },
  200. /* spawn */
  201. { SCMP_SYS(fork), QEMU_SECCOMP_SET_SPAWN,
  202. 0, NULL, SCMP_ACT_ERRNO(EPERM) },
  203. { SCMP_SYS(vfork), QEMU_SECCOMP_SET_SPAWN,
  204. 0, NULL, SCMP_ACT_ERRNO(EPERM) },
  205. { SCMP_SYS(execve), QEMU_SECCOMP_SET_SPAWN,
  206. 0, NULL, SCMP_ACT_ERRNO(EPERM) },
  207. { SCMP_SYS(clone), QEMU_SECCOMP_SET_SPAWN,
  208. ARRAY_SIZE(clone_arg_none), clone_arg_none, SCMP_ACT_ERRNO(EPERM) },
  209. RULE_CLONE_FLAG(CLONE_VM),
  210. RULE_CLONE_FLAG(CLONE_FS),
  211. RULE_CLONE_FLAG(CLONE_FILES),
  212. RULE_CLONE_FLAG(CLONE_SIGHAND),
  213. RULE_CLONE_FLAG(CLONE_THREAD),
  214. RULE_CLONE_FLAG(CLONE_SYSVSEM),
  215. RULE_CLONE_FLAG(CLONE_SETTLS),
  216. RULE_CLONE_FLAG(CLONE_PARENT_SETTID),
  217. RULE_CLONE_FLAG(CLONE_CHILD_CLEARTID),
  218. /*RULE_CLONE_FLAG(CLONE_DETACHED),*/
  219. RULE_CLONE_FLAG(CLONE_PIDFD),
  220. RULE_CLONE_FLAG(CLONE_PTRACE),
  221. RULE_CLONE_FLAG(CLONE_VFORK),
  222. RULE_CLONE_FLAG(CLONE_PARENT),
  223. RULE_CLONE_FLAG(CLONE_NEWNS),
  224. RULE_CLONE_FLAG(CLONE_UNTRACED),
  225. RULE_CLONE_FLAG(CLONE_NEWCGROUP),
  226. RULE_CLONE_FLAG(CLONE_NEWUTS),
  227. RULE_CLONE_FLAG(CLONE_NEWIPC),
  228. RULE_CLONE_FLAG(CLONE_NEWUSER),
  229. RULE_CLONE_FLAG(CLONE_NEWPID),
  230. RULE_CLONE_FLAG(CLONE_NEWNET),
  231. RULE_CLONE_FLAG(CLONE_IO),
  232. #ifdef __SNR_clone3
  233. { SCMP_SYS(clone3), QEMU_SECCOMP_SET_SPAWN,
  234. 0, NULL, SCMP_ACT_ERRNO(ENOSYS) },
  235. #endif
  236. #ifdef __SNR_execveat
  237. { SCMP_SYS(execveat), QEMU_SECCOMP_SET_SPAWN },
  238. #endif
  239. { SCMP_SYS(setns), QEMU_SECCOMP_SET_SPAWN },
  240. { SCMP_SYS(unshare), QEMU_SECCOMP_SET_SPAWN },
  241. /* resource control */
  242. { SCMP_SYS(setpriority), QEMU_SECCOMP_SET_RESOURCECTL,
  243. 0, NULL, SCMP_ACT_ERRNO(EPERM) },
  244. { SCMP_SYS(sched_setparam), QEMU_SECCOMP_SET_RESOURCECTL,
  245. 0, NULL, SCMP_ACT_ERRNO(EPERM) },
  246. { SCMP_SYS(sched_setscheduler), QEMU_SECCOMP_SET_RESOURCECTL,
  247. ARRAY_SIZE(sched_setscheduler_arg), sched_setscheduler_arg,
  248. SCMP_ACT_ERRNO(EPERM) },
  249. { SCMP_SYS(sched_setaffinity), QEMU_SECCOMP_SET_RESOURCECTL,
  250. 0, NULL, SCMP_ACT_ERRNO(EPERM) },
  251. };
  252. static inline __attribute__((unused)) int
  253. qemu_seccomp(unsigned int operation, unsigned int flags, void *args)
  254. {
  255. #ifdef __NR_seccomp
  256. return syscall(__NR_seccomp, operation, flags, args);
  257. #else
  258. errno = ENOSYS;
  259. return -1;
  260. #endif
  261. }
  262. static uint32_t qemu_seccomp_update_action(uint32_t action)
  263. {
  264. #if defined(SECCOMP_GET_ACTION_AVAIL) && defined(SCMP_ACT_KILL_PROCESS) && \
  265. defined(SECCOMP_RET_KILL_PROCESS)
  266. if (action == SCMP_ACT_TRAP) {
  267. static int kill_process = -1;
  268. if (kill_process == -1) {
  269. uint32_t testaction = SECCOMP_RET_KILL_PROCESS;
  270. if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &testaction) == 0) {
  271. kill_process = 1;
  272. } else {
  273. kill_process = 0;
  274. }
  275. }
  276. if (kill_process == 1) {
  277. return SCMP_ACT_KILL_PROCESS;
  278. }
  279. }
  280. #endif
  281. return action;
  282. }
  283. static int seccomp_start(uint32_t seccomp_opts, Error **errp)
  284. {
  285. int rc = -1;
  286. unsigned int i = 0;
  287. scmp_filter_ctx ctx;
  288. ctx = seccomp_init(SCMP_ACT_ALLOW);
  289. if (ctx == NULL) {
  290. error_setg(errp, "failed to initialize seccomp context");
  291. goto seccomp_return;
  292. }
  293. #if defined(CONFIG_SECCOMP_SYSRAWRC)
  294. /*
  295. * This must be the first seccomp_attr_set() call to have full
  296. * error propagation from subsequent seccomp APIs.
  297. */
  298. rc = seccomp_attr_set(ctx, SCMP_FLTATR_API_SYSRAWRC, 1);
  299. if (rc != 0) {
  300. error_setg_errno(errp, -rc,
  301. "failed to set seccomp rawrc attribute");
  302. goto seccomp_return;
  303. }
  304. #endif
  305. rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_TSYNC, 1);
  306. if (rc != 0) {
  307. error_setg_errno(errp, -rc,
  308. "failed to set seccomp thread synchronization");
  309. goto seccomp_return;
  310. }
  311. for (i = 0; i < ARRAY_SIZE(denylist); i++) {
  312. uint32_t action;
  313. if (!(seccomp_opts & denylist[i].set)) {
  314. continue;
  315. }
  316. action = qemu_seccomp_update_action(denylist[i].action);
  317. rc = seccomp_rule_add_array(ctx, action, denylist[i].num,
  318. denylist[i].narg, denylist[i].arg_cmp);
  319. if (rc < 0) {
  320. error_setg_errno(errp, -rc,
  321. "failed to add seccomp denylist rules");
  322. goto seccomp_return;
  323. }
  324. }
  325. rc = seccomp_load(ctx);
  326. if (rc < 0) {
  327. error_setg_errno(errp, -rc,
  328. "failed to load seccomp syscall filter in kernel");
  329. }
  330. seccomp_return:
  331. seccomp_release(ctx);
  332. return rc < 0 ? -1 : 0;
  333. }
  334. int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
  335. {
  336. if (qemu_opt_get_bool(opts, "enable", false)) {
  337. uint32_t seccomp_opts = QEMU_SECCOMP_SET_DEFAULT
  338. | QEMU_SECCOMP_SET_OBSOLETE;
  339. const char *value = NULL;
  340. value = qemu_opt_get(opts, "obsolete");
  341. if (value) {
  342. if (g_str_equal(value, "allow")) {
  343. seccomp_opts &= ~QEMU_SECCOMP_SET_OBSOLETE;
  344. } else if (g_str_equal(value, "deny")) {
  345. /* this is the default option, this if is here
  346. * to provide a little bit of consistency for
  347. * the command line */
  348. } else {
  349. error_setg(errp, "invalid argument for obsolete");
  350. return -1;
  351. }
  352. }
  353. value = qemu_opt_get(opts, "elevateprivileges");
  354. if (value) {
  355. if (g_str_equal(value, "deny")) {
  356. seccomp_opts |= QEMU_SECCOMP_SET_PRIVILEGED;
  357. } else if (g_str_equal(value, "children")) {
  358. seccomp_opts |= QEMU_SECCOMP_SET_PRIVILEGED;
  359. /* calling prctl directly because we're
  360. * not sure if host has CAP_SYS_ADMIN set*/
  361. if (prctl(PR_SET_NO_NEW_PRIVS, 1)) {
  362. error_setg(errp, "failed to set no_new_privs aborting");
  363. return -1;
  364. }
  365. } else if (g_str_equal(value, "allow")) {
  366. /* default value */
  367. } else {
  368. error_setg(errp, "invalid argument for elevateprivileges");
  369. return -1;
  370. }
  371. }
  372. value = qemu_opt_get(opts, "spawn");
  373. if (value) {
  374. if (g_str_equal(value, "deny")) {
  375. seccomp_opts |= QEMU_SECCOMP_SET_SPAWN;
  376. } else if (g_str_equal(value, "allow")) {
  377. /* default value */
  378. } else {
  379. error_setg(errp, "invalid argument for spawn");
  380. return -1;
  381. }
  382. }
  383. value = qemu_opt_get(opts, "resourcecontrol");
  384. if (value) {
  385. if (g_str_equal(value, "deny")) {
  386. seccomp_opts |= QEMU_SECCOMP_SET_RESOURCECTL;
  387. } else if (g_str_equal(value, "allow")) {
  388. /* default value */
  389. } else {
  390. error_setg(errp, "invalid argument for resourcecontrol");
  391. return -1;
  392. }
  393. }
  394. if (seccomp_start(seccomp_opts, errp) < 0) {
  395. return -1;
  396. }
  397. }
  398. return 0;
  399. }
  400. static QemuOptsList qemu_sandbox_opts = {
  401. .name = "sandbox",
  402. .implied_opt_name = "enable",
  403. .head = QTAILQ_HEAD_INITIALIZER(qemu_sandbox_opts.head),
  404. .desc = {
  405. {
  406. .name = "enable",
  407. .type = QEMU_OPT_BOOL,
  408. },
  409. {
  410. .name = "obsolete",
  411. .type = QEMU_OPT_STRING,
  412. },
  413. {
  414. .name = "elevateprivileges",
  415. .type = QEMU_OPT_STRING,
  416. },
  417. {
  418. .name = "spawn",
  419. .type = QEMU_OPT_STRING,
  420. },
  421. {
  422. .name = "resourcecontrol",
  423. .type = QEMU_OPT_STRING,
  424. },
  425. { /* end of list */ }
  426. },
  427. };
  428. static void seccomp_register(void)
  429. {
  430. bool add = false;
  431. /* FIXME: use seccomp_api_get() >= 2 check when released */
  432. #if defined(SECCOMP_FILTER_FLAG_TSYNC)
  433. int check;
  434. /* check host TSYNC capability, it returns errno == ENOSYS if unavailable */
  435. check = qemu_seccomp(SECCOMP_SET_MODE_FILTER,
  436. SECCOMP_FILTER_FLAG_TSYNC, NULL);
  437. if (check < 0 && errno == EFAULT) {
  438. add = true;
  439. }
  440. #endif
  441. if (add) {
  442. qemu_add_opts(&qemu_sandbox_opts);
  443. }
  444. }
  445. opts_init(seccomp_register);