From nobody Fri Apr 26 14:47:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555076009; cv=none; d=zoho.com; s=zohoarc; b=Xm7LX2NEqFYo6eDk5RtFgxtkj8h19DykbGYdKtYvW8PqiHGaWypvz29dpbk6AlZ6SGqCfUbh7jrwFIW6K2AB6kKLheTGjG8YzNIpigwa65bsuHeQ5YpEd4u6fxneOdMUZmo3J/F4oVoAb5oTmsgaFWdHClcQcGdDLwZSbWm/w2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555076009; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=GwqzVjdKg4wx4kB5mgXmTCelMi+x5BDVdKWThYtu6Ro=; b=WNAa3aEJdqOnPohLLQrjRtEYdcZmE+kctZjI4oIGsch5Rn6pd2GL3U6gOxyd8b/iKdAIAARlFRHUA/p+Z8vrZRcHwgMS7NV3Q60sbigj6QDy73iYbFdYzn4W00TZmYkj6ExskDc2isqwSiNUGRVVTVYg28kKibjLaetqUGE/Ki0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1555076009005950.273467455062; Fri, 12 Apr 2019 06:33:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC2C8316B767; Fri, 12 Apr 2019 13:33:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFCE05D9C5; Fri, 12 Apr 2019 13:32:51 +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 92DA2181AC44; Fri, 12 Apr 2019 13:32:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3CDWUpU009196 for ; Fri, 12 Apr 2019 09:32:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0A366013D; Fri, 12 Apr 2019 13:32:30 +0000 (UTC) Received: from caroline (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74E34600C5 for ; Fri, 12 Apr 2019 13:32:28 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline (Postfix) with ESMTP id DD3A6120036 for ; Fri, 12 Apr 2019 15:32:26 +0200 (CEST) From: Martin Kletzander To: libvir-list@redhat.com Date: Fri, 12 Apr 2019 15:32:21 +0200 Message-Id: <0e68f22354d6d4d6ce607485da4ee370d10021e0.1555075941.git.mkletzan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Label uniqDir when probing capabilities 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 12 Apr 2019 13:33:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This does not cause a problem in usual scenarios thanks to us allowing CAP_DAC_OVERRIDE for the qemu process, however in some scenarios this might= be an issue because the directory is created with mkdtemp(3) which explicitly creates that with 0700 permissions and qemu running as non-root cannot acce= ss that. The scenarios include: - Builds without CAPNG - Running libvirtd in a container [1] - and possibly others. [1] https://github.com/kubevirt/kubevirt/pull/2181#issuecomment-481840304 Signed-off-by: Martin Kletzander Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 47d8ca2ff163..2e2c4812fef7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8447,6 +8447,19 @@ qemuProcessQMPNew(const char *binary, } =20 =20 +static int +qemuProcessQEMULabelUniqPath(qemuProcessQMPPtr proc) { + /* We cannot use the security driver here, but we should not need to. = */ + if (chown(proc->uniqDir, proc->runUid, -1) < 0) { + virReportSystemError(errno, + "Cannot chown uniq path: %s", proc->uniqDir); + return -1; + } + + return 0; +} + + static int qemuProcessQMPInit(qemuProcessQMPPtr proc) { @@ -8466,6 +8479,9 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc) goto cleanup; } =20 + if (qemuProcessQEMULabelUniqPath(proc) < 0) + goto cleanup; + if (virAsprintf(&proc->monpath, "%s/%s", proc->uniqDir, "qmp.monitor") < 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list