From patchwork Mon Oct 22 12:33:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10652059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B864C921 for ; Mon, 22 Oct 2018 13:08:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B082D289B4 for ; Mon, 22 Oct 2018 13:08:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2A7228A64; Mon, 22 Oct 2018 13:08:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3EBED289B4 for ; Mon, 22 Oct 2018 13:08:49 +0000 (UTC) Received: from localhost ([::1]:34948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEZwu-0002FC-DQ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Oct 2018 09:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEZPq-0002Rh-TD for qemu-devel@nongnu.org; Mon, 22 Oct 2018 08:34:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEZPn-0003FB-Ln for qemu-devel@nongnu.org; Mon, 22 Oct 2018 08:34:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17351) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEZPn-0002yJ-5y for qemu-devel@nongnu.org; Mon, 22 Oct 2018 08:34:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CFFE9E614 for ; Mon, 22 Oct 2018 12:34:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-117-34.ams2.redhat.com [10.36.117.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6556C105704F; Mon, 22 Oct 2018 12:34:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 511AA11415DD; Mon, 22 Oct 2018 14:34:14 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2018 14:33:52 +0200 Message-Id: <20181022123413.28044-20-armbru@redhat.com> In-Reply-To: <20181022123413.28044-1-armbru@redhat.com> References: <20181022123413.28044-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 22 Oct 2018 12:34:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 19/40] seccomp: Clean up error reporting in parse_sandbox() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Otubo Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Calling error_report() in a function that takes an Error ** argument is suspicious. parse_sandbox() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Eduardo Otubo Signed-off-by: Markus Armbruster Reviewed-by: Marc-André Lureau Acked-by: Eduardo Otubo Message-Id: <20181017082702.5581-18-armbru@redhat.com> --- qemu-seccomp.c | 18 +++++++++--------- vl.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/qemu-seccomp.c b/qemu-seccomp.c index 1baa5c69ed..5c73e6ad05 100644 --- a/qemu-seccomp.c +++ b/qemu-seccomp.c @@ -12,11 +12,12 @@ * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ + #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/module.h" -#include "qemu/error-report.h" #include #include #include "sysemu/seccomp.h" @@ -190,7 +191,7 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) * to provide a little bit of consistency for * the command line */ } else { - error_report("invalid argument for obsolete"); + error_setg(errp, "invalid argument for obsolete"); return -1; } } @@ -205,14 +206,13 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) /* calling prctl directly because we're * not sure if host has CAP_SYS_ADMIN set*/ if (prctl(PR_SET_NO_NEW_PRIVS, 1)) { - error_report("failed to set no_new_privs " - "aborting"); + error_setg(errp, "failed to set no_new_privs aborting"); return -1; } } else if (g_str_equal(value, "allow")) { /* default value */ } else { - error_report("invalid argument for elevateprivileges"); + error_setg(errp, "invalid argument for elevateprivileges"); return -1; } } @@ -224,7 +224,7 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) } else if (g_str_equal(value, "allow")) { /* default value */ } else { - error_report("invalid argument for spawn"); + error_setg(errp, "invalid argument for spawn"); return -1; } } @@ -236,14 +236,14 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) } else if (g_str_equal(value, "allow")) { /* default value */ } else { - error_report("invalid argument for resourcecontrol"); + error_setg(errp, "invalid argument for resourcecontrol"); return -1; } } if (seccomp_start(seccomp_opts) < 0) { - error_report("failed to install seccomp syscall filter " - "in the kernel"); + error_setg(errp, "failed to install seccomp syscall filter " + "in the kernel"); return -1; } } diff --git a/vl.c b/vl.c index db83cfe2e9..d7b604c97e 100644 --- a/vl.c +++ b/vl.c @@ -3973,8 +3973,8 @@ int main(int argc, char **argv, char **envp) #ifdef CONFIG_SECCOMP olist = qemu_find_opts_err("sandbox", NULL); - if (olist && qemu_opts_foreach(olist, parse_sandbox, NULL, NULL)) { - exit(1); + if (olist) { + qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal); } #endif