[{"id":1765336,"web_url":"http://patchwork.ozlabs.org/comment/1765336/","msgid":"<43a508ee-b3c8-bc0f-e29f-892bbfa44308@redhat.com>","list_archive_url":null,"date":"2017-09-08T13:10:55","subject":"Re: [Qemu-devel] [PATCHv6 2/5] seccomp: add obsolete argument to\n\tcommand line","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/people/66152/","name":"Thomas Huth","email":"thuth@redhat.com"},"content":"On 08.09.2017 13:44, Eduardo Otubo wrote:\n> This patch introduces the argument [,obsolete=allow] to the `-sandbox on'\n> option. It allows Qemu to run safely on old system that still relies on\n> old system calls.\n> \n> Signed-off-by: Eduardo Otubo <otubo@redhat.com>\n> ---\n>  include/sysemu/seccomp.h |  3 ++-\n>  qemu-options.hx          | 12 ++++++++++--\n>  qemu-seccomp.c           | 19 ++++++++++++++++++-\n>  vl.c                     | 23 ++++++++++++++++++++++-\n>  4 files changed, 52 insertions(+), 5 deletions(-)\n\nReviewed-by: Thomas Huth <thuth@redhat.com>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpd4r49RBz9ryk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 23:11:40 +1000 (AEST)","from localhost ([::1]:45410 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dqJ4M-0005j6-Lm\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 09:11:38 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:57567)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dqJ3o-0005dQ-Hb\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:11:08 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dqJ3l-0004Pd-BB\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:11:04 -0400","from mx1.redhat.com ([209.132.183.28]:49526)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>) id 1dqJ3l-0004Oe-4l\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:11:01 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 339F34A6E6\n\tfor <qemu-devel@nongnu.org>; Fri,  8 Sep 2017 13:11:00 +0000 (UTC)","from [10.36.116.21] (ovpn-116-21.ams2.redhat.com [10.36.116.21])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id C4D355C8B7;\n\tFri,  8 Sep 2017 13:10:56 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 339F34A6E6","To":"Eduardo Otubo <otubo@redhat.com>, qemu-devel@nongnu.org","References":"<20170908114407.25906-1-otubo@redhat.com>\n\t<20170908114407.25906-3-otubo@redhat.com>","From":"Thomas Huth <thuth@redhat.com>","Message-ID":"<43a508ee-b3c8-bc0f-e29f-892bbfa44308@redhat.com>","Date":"Fri, 8 Sep 2017 15:10:55 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170908114407.25906-3-otubo@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tFri, 08 Sep 2017 13:11:00 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCHv6 2/5] seccomp: add obsolete argument to\n\tcommand line","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1768693,"web_url":"http://patchwork.ozlabs.org/comment/1768693/","msgid":"<20170914155012.GD11763@redhat.com>","list_archive_url":null,"date":"2017-09-14T15:50:12","subject":"Re: [Qemu-devel] [PATCHv6 2/5] seccomp: add obsolete argument to\n\tcommand line","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Fri, Sep 08, 2017 at 01:44:04PM +0200, Eduardo Otubo wrote:\n> This patch introduces the argument [,obsolete=allow] to the `-sandbox on'\n> option. It allows Qemu to run safely on old system that still relies on\n> old system calls.\n> \n> Signed-off-by: Eduardo Otubo <otubo@redhat.com>\n> ---\n>  include/sysemu/seccomp.h |  3 ++-\n>  qemu-options.hx          | 12 ++++++++++--\n>  qemu-seccomp.c           | 19 ++++++++++++++++++-\n>  vl.c                     | 23 ++++++++++++++++++++++-\n>  4 files changed, 52 insertions(+), 5 deletions(-)\n> \n> diff --git a/include/sysemu/seccomp.h b/include/sysemu/seccomp.h\n> index 23b9c3c789..215138a372 100644\n> --- a/include/sysemu/seccomp.h\n> +++ b/include/sysemu/seccomp.h\n> @@ -16,8 +16,9 @@\n>  #define QEMU_SECCOMP_H\n>  \n>  #define QEMU_SECCOMP_SET_DEFAULT     (1 << 0)\n> +#define QEMU_SECCOMP_SET_OBSOLETE    (1 << 1)\n>  \n>  #include <seccomp.h>\n>  \n> -int seccomp_start(void);\n> +int seccomp_start(uint32_t seccomp_opts);\n>  #endif\n> diff --git a/qemu-options.hx b/qemu-options.hx\n> index 9f6e2adfff..72150c6b84 100644\n> --- a/qemu-options.hx\n> +++ b/qemu-options.hx\n> @@ -4017,13 +4017,21 @@ Old param mode (ARM only).\n>  ETEXI\n>  \n>  DEF(\"sandbox\", HAS_ARG, QEMU_OPTION_sandbox, \\\n> -    \"-sandbox <arg>  Enable seccomp mode 2 system call filter (default 'off').\\n\",\n> +    \"-sandbox on[,obsolete=allow|deny]\\n\" \\\n> +    \"                Enable seccomp mode 2 system call filter (default 'off').\\n\" \\\n> +    \"                use 'obsolete' to allow obsolete system calls that are provided\\n\" \\\n> +    \"                    by the kernel, but typically no longer used by modern\\n\" \\\n> +    \"                    C library implementations.\\n\",\n>      QEMU_ARCH_ALL)\n>  STEXI\n> -@item -sandbox @var{arg}\n> +@item -sandbox @var{arg}[,obsolete=@var{string}]\n>  @findex -sandbox\n>  Enable Seccomp mode 2 system call filter. 'on' will enable syscall filtering and 'off' will\n>  disable it.  The default is 'off'.\n> +@table @option\n> +@item obsolete=@var{string}\n> +Enable Obsolete system calls\n> +@end table\n>  ETEXI\n>  \n>  DEF(\"readconfig\", HAS_ARG, QEMU_OPTION_readconfig,\n> diff --git a/qemu-seccomp.c b/qemu-seccomp.c\n> index f66613fc71..8a5fbd2ff1 100644\n> --- a/qemu-seccomp.c\n> +++ b/qemu-seccomp.c\n> @@ -55,9 +55,22 @@ static const struct QemuSeccompSyscall blacklist[] = {\n>      { SCMP_SYS(tuxcall),                QEMU_SECCOMP_SET_DEFAULT },\n>      { SCMP_SYS(ulimit),                 QEMU_SECCOMP_SET_DEFAULT },\n>      { SCMP_SYS(vserver),                QEMU_SECCOMP_SET_DEFAULT },\n> +    /* obsolete */\n> +    { SCMP_SYS(readdir),                QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(_sysctl),                QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(bdflush),                QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(create_module),          QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(get_kernel_syms),        QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(query_module),           QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(sgetmask),               QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(ssetmask),               QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(sysfs),                  QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(uselib),                 QEMU_SECCOMP_SET_OBSOLETE },\n> +    { SCMP_SYS(ustat),                  QEMU_SECCOMP_SET_OBSOLETE },\n>  };\n>  \n> -int seccomp_start(void)\n> +\n> +int seccomp_start(uint32_t seccomp_opts)\n>  {\n>      int rc = 0;\n>      unsigned int i = 0;\n> @@ -70,6 +83,10 @@ int seccomp_start(void)\n>      }\n>  \n>      for (i = 0; i < ARRAY_SIZE(blacklist); i++) {\n> +        if (!(seccomp_opts & blacklist[i].set)) {\n> +            continue;\n> +        }\n> +\n>          rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, blacklist[i].num, 0);\n>          if (rc < 0) {\n>              goto seccomp_return;\n> diff --git a/vl.c b/vl.c\n> index 76e0b3a946..62b71dd529 100644\n> --- a/vl.c\n> +++ b/vl.c\n> @@ -271,6 +271,10 @@ static QemuOptsList qemu_sandbox_opts = {\n>              .name = \"enable\",\n>              .type = QEMU_OPT_BOOL,\n>          },\n> +        {\n> +            .name = \"obsolete\",\n> +            .type = QEMU_OPT_STRING,\n> +        },\n>          { /* end of list */ }\n>      },\n>  };\n> @@ -1034,7 +1038,24 @@ static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)\n>  {\n>      if (qemu_opt_get_bool(opts, \"enable\", false)) {\n>  #ifdef CONFIG_SECCOMP\n> -        if (seccomp_start() < 0) {\n> +        uint32_t seccomp_opts = QEMU_SECCOMP_SET_DEFAULT\n> +                | QEMU_SECCOMP_SET_OBSOLETE;\n> +        const char *value = NULL;\n> +\n> +        value = qemu_opt_get(opts, \"obsolete\");\n> +        if (value) {\n> +            if (g_str_equal(value, \"allow\")) {\n> +                seccomp_opts &= ~QEMU_SECCOMP_SET_OBSOLETE;\n> +            } else if (g_str_equal(value, \"deny\")) {\n> +                /* this is the default option, this if is here\n> +                 * to provide a little bit of consistency for\n> +                 * the command line */\n> +            } else {\n> +                error_report(\"invalid argument for obsolete\");\n\nNeeds a 'return -1;'\n\n> +            }\n> +        }\n> +\n> +        if (seccomp_start(seccomp_opts) < 0) {\n>              error_report(\"failed to install seccomp syscall filter \"\n>                           \"in the kernel\");\n>              return -1;\n\nIf that bug is fixed\n\nReviewed-by: Daniel P. Berrange <berrange@redhat.com>\n\n\nRegards,\nDaniel","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtNKq0TQwz9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 01:50:55 +1000 (AEST)","from localhost ([::1]:48557 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dsWPl-0005Cq-7U\n\tfor incoming@patchwork.ozlabs.org; Thu, 14 Sep 2017 11:50:53 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:58926)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1dsWPH-00051q-51\n\tfor qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:50:24 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1dsWPE-0000qo-P9\n\tfor qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:50:23 -0400","from mx1.redhat.com ([209.132.183.28]:41996)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1dsWPE-0000q9-Ft\n\tfor qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:50:20 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 5762F7E420\n\tfor <qemu-devel@nongnu.org>; Thu, 14 Sep 2017 15:50:19 +0000 (UTC)","from redhat.com (ovpn-116-81.ams2.redhat.com [10.36.116.81])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 57DE75C3FD;\n\tThu, 14 Sep 2017 15:50:15 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 5762F7E420","Date":"Thu, 14 Sep 2017 16:50:12 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Eduardo Otubo <otubo@redhat.com>","Message-ID":"<20170914155012.GD11763@redhat.com>","References":"<20170908114407.25906-1-otubo@redhat.com>\n\t<20170908114407.25906-3-otubo@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20170908114407.25906-3-otubo@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tThu, 14 Sep 2017 15:50:19 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCHv6 2/5] seccomp: add obsolete argument to\n\tcommand line","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"thuth@redhat.com, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]