From patchwork Tue Aug 14 21:44:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Otubo X-Patchwork-Id: 177463 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9A7162C0084 for ; Wed, 15 Aug 2012 07:45:11 +1000 (EST) Received: from localhost ([::1]:41459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1OvF-0006pr-Ku for incoming@patchwork.ozlabs.org; Tue, 14 Aug 2012 17:45:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1Ouo-0006UG-Na for qemu-devel@nongnu.org; Tue, 14 Aug 2012 17:44:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1Oum-0004bN-NA for qemu-devel@nongnu.org; Tue, 14 Aug 2012 17:44:42 -0400 Received: from e24smtp04.br.ibm.com ([32.104.18.25]:46686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1Oum-0004ZP-At for qemu-devel@nongnu.org; Tue, 14 Aug 2012 17:44:40 -0400 Received: from /spool/local by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Aug 2012 18:44:35 -0300 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Aug 2012 18:44:34 -0300 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.13.184.25]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 148D83520052 for ; Tue, 14 Aug 2012 17:44:30 -0400 (EDT) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay03.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7ELheTx27721808 for ; Tue, 14 Aug 2012 18:43:40 -0300 Received: from d24av05.br.ibm.com (loopback [127.0.0.1]) by d24av05.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7ELiWKc029091 for ; Tue, 14 Aug 2012 18:44:33 -0300 Received: from vader.br.ibm.com (dhcp-9-18-235-154.br.ibm.com [9.18.235.154]) by d24av05.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7ELiWEY029068; Tue, 14 Aug 2012 18:44:32 -0300 From: Eduardo Otubo To: qemu-devel@nongnu.org Date: Tue, 14 Aug 2012 18:44:08 -0300 Message-Id: <1344980648-18723-5-git-send-email-otubo@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1344980648-18723-1-git-send-email-otubo@linux.vnet.ibm.com> References: <1344980648-18723-1-git-send-email-otubo@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12081421-8936-0000-0000-000007B2A2F4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.104.18.25 Cc: pmoore@redhat.com, aliguori@us.ibm.com, wad@chromium.org, coreyb@linux.vnet.ibm.com, blauwirbel@gmail.com, Eduardo Otubo Subject: [Qemu-devel] [PATCH v7 4/4] Command line support for seccomp with -sandbox X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org v7: * New in v7 * The seccomp filter can be switched on and off using the command line option "-sandbox", the default value is off. Signed-off-by: Eduardo Otubo --- qemu-config.c | 13 +++++++++++++ qemu-config.h | 1 + qemu-options.hx | 10 ++++++++++ vl.c | 17 +++++++++-------- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/qemu-config.c b/qemu-config.c index 5c3296b..b1e2277 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -362,6 +362,18 @@ static QemuOptsList qemu_global_opts = { }, }; +QemuOptsList qemu_sandbox_opts = { + .name = "sandbox", + .head = QTAILQ_HEAD_INITIALIZER(qemu_sandbox_opts.head), + .desc = { + { + .name = "sandbox", + .type = QEMU_OPT_BOOL, + }, + { /* end of list */ } + }, +}; + static QemuOptsList qemu_mon_opts = { .name = "mon", .implied_opt_name = "chardev", @@ -641,6 +653,7 @@ static QemuOptsList *vm_config_groups[32] = { &qemu_machine_opts, &qemu_boot_opts, &qemu_iscsi_opts, + &qemu_sandbox_opts, NULL, }; diff --git a/qemu-config.h b/qemu-config.h index 12ddf3e..5557562 100644 --- a/qemu-config.h +++ b/qemu-config.h @@ -6,6 +6,7 @@ extern QemuOptsList qemu_fsdev_opts; extern QemuOptsList qemu_virtfs_opts; extern QemuOptsList qemu_spice_opts; +extern QemuOptsList qemu_sandbox_opts; QemuOptsList *qemu_find_opts(const char *group); QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); diff --git a/qemu-options.hx b/qemu-options.hx index 47cb5bd..a26f640 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2720,6 +2720,16 @@ STEXI Old param mode (ARM only). ETEXI +#ifdef CONFIG_SECCOMP +DEF("sandbox", 0, QEMU_OPTION_sandbox, \ + "-sandbox Enable Seccomp mode 2 system call filter. Default value is disabled,\n", QEMU_ARCH_ALL) +STEXI +@item -sandbox +@findex -sandbox +Enable Seccomp mode 2 system call filter. Default value is disabled, +ETEXI +#endif + DEF("readconfig", HAS_ARG, QEMU_OPTION_readconfig, "-readconfig \n", QEMU_ARCH_ALL) STEXI diff --git a/vl.c b/vl.c index 2c62efc..775b6af 100644 --- a/vl.c +++ b/vl.c @@ -2304,14 +2304,6 @@ int main(int argc, char **argv, char **envp) const char *trace_events = NULL; const char *trace_file = NULL; -#ifdef CONFIG_SECCOMP - if (seccomp_start() < 0) { - fprintf(stderr, - "seccomp: failed to install syscall filter in the kernel\n"); - exit(1); - } -#endif - atexit(qemu_run_exit_notifiers); error_set_progname(argv[0]); @@ -3215,6 +3207,15 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_qtest_log: qtest_log = optarg; break; +#ifdef CONFIG_SECCOMP + case QEMU_OPTION_sandbox: + if (seccomp_start() < 0) { + fprintf(stderr, + "seccomp: failed to install syscall filter in the kernel\n"); + exit(1); + } + break; +#endif default: os_parse_cmd_args(popt->index, optarg); }