From nobody Thu May 2 01:02:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=canonical.com ARC-Seal: i=1; a=rsa-sha256; t=1590499436; cv=none; d=zohomail.com; s=zohoarc; b=Pqn9PoWVysxOhzRj0Ky9PEaxDjks48mBxJKdCGbRZFUALI3k82Lp2q9hnCdCii7eq0ux05YCLsg/f2ROJzVmPCXhK5D/YUUUwb8GjB+6KcGl9NAHbymKaBxC0zgERl3wvco9RbXn2qwYnPV8GQez/ST0aFyex1tH4ovm4oxCtFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590499436; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=5JCpDNWOl5lpOlmv62srZo+AnJUIGcDSBdkNCUmnJJ8=; b=EYFI5PlbFuPlmv5IGMBajJV+5niLjk6aPh6pc1kD+M9SFQLvM8qYA6A1B82N5Nv7HEko4yuNuZ33owdRqA/Hs7XpP9AuLMo/Bgn4VMfwdiPCfPZlZSjosMS4Ie3vgS7UhgsFTYkZpP8VT6g/lqFS9qcqXE22zOgNfLMxY7QWhj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1590499436391190.19277896332835; Tue, 26 May 2020 06:23:56 -0700 (PDT) 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-84-7cNEiPgLPGqVbU74fScPsw-1; Tue, 26 May 2020 09:23:51 -0400 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 4298080183C; Tue, 26 May 2020 13:23:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 207CB19D61; Tue, 26 May 2020 13:23:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BE6455FBEC; Tue, 26 May 2020 13:23:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04QDNiNc011949 for ; Tue, 26 May 2020 09:23:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25A909D70; Tue, 26 May 2020 13:23:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1835B5EDE6 for ; Tue, 26 May 2020 13:23:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C11248F7A25 for ; Tue, 26 May 2020 13:23:41 +0000 (UTC) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323-2nzw504SMdumIsCFTIl80w-1; Tue, 26 May 2020 09:23:35 -0400 Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jdZYM-00050h-6G; Tue, 26 May 2020 13:23:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590499434; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5JCpDNWOl5lpOlmv62srZo+AnJUIGcDSBdkNCUmnJJ8=; b=IlHBU+P3dB2aJdO7H5pfcCloYYAQAH5QzgJZW2WnduBpRd75LEKzQzIRx7bV2ibI0z+FPH 5ClRl/dn1LByjhpuaqkxIOUhdc1mkQYwodAISOqYc87mnI/dKlYF+Qvn/ffUIxop98fa/Z cbJkKgOcPkJZVlh55qM9ImXaDJvbvSE= X-MC-Unique: 7cNEiPgLPGqVbU74fScPsw-1 X-MC-Unique: 2nzw504SMdumIsCFTIl80w-1 From: Christian Ehrhardt To: libvir-list@redhat.com Subject: [PATCH v2] security: don't fail if built without attr support Date: Tue, 26 May 2020 15:23:32 +0200 Message-Id: <20200526132332.3605942-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Christian Ehrhardt X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If built without attr support removing any image will trigger qemuBlockRemoveImageMetadata (the one that emits the warning) -> qemuSecurityMoveImageMetadata -> virSecurityManagerMoveImageMetadata -> virSecurityDACMoveImageMetadata -> virSecurityDACMoveImageMetadataHelper -> virProcessRunInFork (spawns subprocess) -> virSecurityMoveRememberedLabel In there due to !HAVE_LIBATTR virFileGetXAttrQuiet will return ENOSYS and from there the chain will error out. That is wrong and looks like: libvirtd[6320]: internal error: child reported (status=3D125): libvirtd[6320]: Unable to remove disk metadata on vm testguest from /var/lib/uvtool/libvirt/images/testguest.qcow (disk target vda) This change makes virSecurityDACMoveImageMetadataHelper and virSecuritySELinuxMoveImageMetadataHelper accept that error code gracefully and in that sense it is an extension of: 5214b2f1a3f "security: Don't skip label restore on file systems lacking XAT= TRs" which does the same for other call chains into the virFile*XAttr functions. Signed-off-by: Christian Ehrhardt Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 6 ++++++ src/security/security_selinux.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index bdc2d7edf3..7b95a6f86d 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1117,6 +1117,12 @@ virSecurityDACMoveImageMetadataHelper(pid_t pid G_GN= UC_UNUSED, =20 ret =3D virSecurityMoveRememberedLabel(SECURITY_DAC_NAME, data->src, d= ata->dst); virSecurityManagerMetadataUnlock(data->mgr, &state); + + if (ret =3D=3D -2) { + /* Libvirt built without XATTRS */ + ret =3D 0; + } + return ret; } =20 diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 9a929debe1..7bb7c2b7b1 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1975,6 +1975,12 @@ virSecuritySELinuxMoveImageMetadataHelper(pid_t pid = G_GNUC_UNUSED, =20 ret =3D virSecurityMoveRememberedLabel(SECURITY_SELINUX_NAME, data->sr= c, data->dst); virSecurityManagerMetadataUnlock(data->mgr, &state); + + if (ret =3D=3D -2) { + /* Libvirt built without XATTRS */ + ret =3D 0; + } + return ret; } =20 --=20 2.26.0