From nobody Thu May 2 09:18:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605248767; cv=none; d=zohomail.com; s=zohoarc; b=RpV6hw6NNlJlVj32QDnd3M4IQsnjcfRGTonVBkJjhkp2PG3FC+oYRvNFGNifjKx7XqB7829xLLElq1jY4+9ECqRknNX5m6C8jeGBrxeftoPvXpFlWLxr3rQviKrnzHX3nuHt8A06MSQ/+VeJ4BWqyP2wuoxoMrfdXN9VFdt94bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605248767; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aTb81/Lh7q1vAUezGh9u1kyYiK34oKEX/gFX1rXJ2mY=; b=dVHLOxZw0QpF390vF/cYb1WvRHVsqnCYQvc5k+O6emih8vDwz2aDXR7e0i1hlPS42t5pSWLbzfzyHWjYEH8/yh3ieYDKeGo0r3QYwGqg0yfSCF75TKLSdk4Vwl6/0YQ2IGWgtBbsjJdtxTdRUHwH8l1OiuiA6L6E0EWKaiY+gHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605248767225429.9850923642591; Thu, 12 Nov 2020 22:26:07 -0800 (PST) Received: from localhost ([::1]:49386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdSX8-0008Rm-50 for importer@patchew.org; Fri, 13 Nov 2020 01:26:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdSVD-00073f-8j for qemu-devel@nongnu.org; Fri, 13 Nov 2020 01:24:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kdSVA-00059G-PI for qemu-devel@nongnu.org; Fri, 13 Nov 2020 01:24:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-bD0dRGVXNKSfnVb46LzQOA-1; Fri, 13 Nov 2020 01:24:01 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 667CB80475F for ; Fri, 13 Nov 2020 06:24:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-103.ams2.redhat.com [10.36.112.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3545119C66; Fri, 13 Nov 2020 06:24:00 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A385411386A3; Fri, 13 Nov 2020 07:23:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605248643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aTb81/Lh7q1vAUezGh9u1kyYiK34oKEX/gFX1rXJ2mY=; b=Lav+AMKFv/uPG9yzSy/5X+0KfiSkd5hgkA8IpwMK/+X7PwSqnc7tEMKeDc9wwPhfXvSEQz jjrUfltCJFBw3sXsuIvRzKxwo3JT5dE2ANIEebDgy3dqDv0M29uzXADOGIwR29xmPzqJQP 9Hg30zy86VRUFNMJAKv7JSwxnfNItmk= X-MC-Unique: bD0dRGVXNKSfnVb46LzQOA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 1/2] authz-list-file: Fix file read error handling Date: Fri, 13 Nov 2020 07:23:57 +0100 Message-Id: <20201113062358.2563662-2-armbru@redhat.com> In-Reply-To: <20201113062358.2563662-1-armbru@redhat.com> References: <20201113062358.2563662-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/12 16:09:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. qauthz_list_file_complete() is wrong that way: it passes @errp to qauthz_list_file_complete() without checking for failure. If it runs into another failure, it trips error_setv()'s assertion. Reproducer: $ qemu-system-x86_64 -nodefaults -S -display none -object authz-list-fi= le,id=3Dauthz0,filename=3D qemu-system-x86_64: ../util/error.c:59: error_setv: Assertion `*errp = =3D=3D NULL' failed. Aborted (core dumped) Fix it to check for failure. Fixes: 55d869846de802a16af1a50584c51737bd664387 Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- authz/listfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/authz/listfile.c b/authz/listfile.c index 24feac35ab..1421e674a4 100644 --- a/authz/listfile.c +++ b/authz/listfile.c @@ -128,6 +128,9 @@ qauthz_list_file_complete(UserCreatable *uc, Error **er= rp) } =20 fauthz->list =3D qauthz_list_file_load(fauthz, errp); + if (!fauthz->list) { + return; + } =20 if (!fauthz->refresh) { return; --=20 2.26.2 From nobody Thu May 2 09:18:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605248696; cv=none; d=zohomail.com; s=zohoarc; b=kKUKQkyUkTQ7BKpF0QDkT5sJ8ukmwSqV0Cz8vQGIGaXbySTq3AbkSXkvyk+/ZOKpGK4ehHZnncQqi1ChC9ctZ376CGapAJrszu+T4+fDbCbnSdb0PvfncYcPiGHVy+41JQvC48QEctX43JuZQy5qp0tc8Y9Rrp4oJJ7MILY8UlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605248696; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YAJL1uf0IbqXO0E0qNC9ogPKUa23x5dtvX4jxQOwpL0=; b=UXGW9kcJH8vPRVt0l+Krbzg/HLQundXYxJyF7m9COwLejbnfGRTZb5QGD3kRa4gZBxjC4V1l26nAfnFqTkSYRoG7t+mFPVZ3IpQm/XtYlKHkDGtV2TPkzyV8hsGjl3cOO+zrNU/sgiRe49bvm3Ey4zf5KJATJk0vk7ZKQwCuFv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605248696393125.31859806236787; Thu, 12 Nov 2020 22:24:56 -0800 (PST) Received: from localhost ([::1]:47268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdSVx-0007TI-UZ for importer@patchew.org; Fri, 13 Nov 2020 01:24:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdSVD-00073e-56 for qemu-devel@nongnu.org; Fri, 13 Nov 2020 01:24:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kdSVA-00059F-MQ for qemu-devel@nongnu.org; Fri, 13 Nov 2020 01:24:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-fD0zKPATM5SOyHvirG5L0g-1; Fri, 13 Nov 2020 01:24:01 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 627EE8049D5 for ; Fri, 13 Nov 2020 06:24:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-103.ams2.redhat.com [10.36.112.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 342301002C0D; Fri, 13 Nov 2020 06:24:00 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A6D3D1138603; Fri, 13 Nov 2020 07:23:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605248643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YAJL1uf0IbqXO0E0qNC9ogPKUa23x5dtvX4jxQOwpL0=; b=HaD7w3wwkWqXWz7Ixh0hxSHV2bp9PjdEqMhLjpasa2GtXaGWTelJl35mvFhPNpenljOo7k 3ygTsckoWtctP0aigeYzMa4YoLaXByCH+kasbvoIzNydtY2R6PPoJ6HXfQc0WxjImKiyBE eMB0DoOFm9+fQBEhIXk7bUUzAD/0bOM= X-MC-Unique: fD0zKPATM5SOyHvirG5L0g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 2/2] authz-list-file: Improve an error message Date: Fri, 13 Nov 2020 07:23:58 +0100 Message-Id: <20201113062358.2563662-3-armbru@redhat.com> In-Reply-To: <20201113062358.2563662-1-armbru@redhat.com> References: <20201113062358.2563662-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/12 08:00:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When qauthz_list_file_load() rejects JSON values other than JSON object with a rather confusing error message: $ echo 1 | qemu-system-x86_64 -nodefaults -S -display none -object aut= hz-list-file,id=3Dauthz0,filename=3D/dev/stdin qemu-system-x86_64: -object authz-list-file,id=3Dauthz0,filename=3D/dev= /stdin: Invalid parameter type for 'obj', expected: dict Improve to qemu-system-x86_64: -object authz-list-file,id=3Dauthz0,filename=3D/dev= /stdin: File '/dev/stdin' must contain a JSON object Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- authz/listfile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/authz/listfile.c b/authz/listfile.c index 1421e674a4..da3a0e69a2 100644 --- a/authz/listfile.c +++ b/authz/listfile.c @@ -73,7 +73,8 @@ qauthz_list_file_load(QAuthZListFile *fauthz, Error **err= p) =20 pdict =3D qobject_to(QDict, obj); if (!pdict) { - error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "obj", "dict"); + error_setg(errp, "File '%s' must contain a JSON object", + fauthz->filename); goto cleanup; } =20 --=20 2.26.2