From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=b6BpZaFE; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 8F73E5A026F for ; Tue, 07 Oct 2025 18:13:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759853626; 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: in-reply-to:in-reply-to:references:references; bh=qzVT6N70FD897t1PqauiyDu2EU2jcMIDQjKlWrmtePg=; b=b6BpZaFEZxJqdHuUCQBOXiNpKGTphqLi7zINnkEFFkf7DpsryVOloPzKpk0c9F2LjrGFD0 BZ+MZRJxCXawBTdsW0ZG1Ue9dNXPKuXded3sD7QIJqBlu8zQDl4rWuRq/jMwG/et2UYp9t Gd0cPSqFhhZrhMtcLlhCJptXNGZ7o1g= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-00ZWUOg_MtC6juFHnfwNrA-1; Tue, 07 Oct 2025 12:13:43 -0400 X-MC-Unique: 00ZWUOg_MtC6juFHnfwNrA-1 X-Mimecast-MFC-AGG-ID: 00ZWUOg_MtC6juFHnfwNrA_1759853622 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C810C1956089; Tue, 7 Oct 2025 16:13:41 +0000 (UTC) Received: from localhost (unknown [10.45.224.22]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2A23D19560A2; Tue, 7 Oct 2025 16:13:39 +0000 (UTC) Date: Tue, 7 Oct 2025 17:13:38 +0100 From: "Richard W.M. Jones" To: Stefano Brivio Subject: Re: [PATCH] isolation: keep CAP_DAC_OVERRIDE initially Message-ID: <20251007161338.GY1460@redhat.com> References: <8635494bf4747935bc2179bdb37c8c2cbbe4ed55.1759839307.git.crobinso@redhat.com> <20251007180232.328feebc@elisabeth> MIME-Version: 1.0 In-Reply-To: <20251007180232.328feebc@elisabeth> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sniiqycsbIAHaP4TomV4-AKBGFPBbUiCzc5LUycNCaY_1759853622 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Message-ID-Hash: AV5DHMZDAAREXCIT4E76SUL3QNC6AZN7 X-Message-ID-Hash: AV5DHMZDAAREXCIT4E76SUL3QNC6AZN7 X-MailFrom: rjones@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Cole Robinson , David Gibson , passt-dev@passt.top, Yumei Huang X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Oct 07, 2025 at 06:02:32PM +0200, Stefano Brivio wrote: > [Cc: Yumei as this is somewhat related to > https://archives.passt.top/passt-dev/20250926011714.5978-1-yuhuang@redhat.com/, > and David as he wrote most of this part] > > On Tue, 7 Oct 2025 08:16:39 -0400 > Cole Robinson wrote: > > > Reproducer that I'd expect to work > > > > $ cd $HOME > > $ sudo passt --runas $UID --socket foo.sock > > Failed to bind UNIX domain socket: Permission denied > > > > A more practical example is for libguestfs apps when run as user=root. > > > > + libguestfs connects to libvirt qemu:///system > > + libvirt qemu:///system defaults to user=qemu. > > + chowns passt runtime dir to user=qemu > > + libguestfs instead requests the VM run as user=root > > + patches in progress but we are blocked by this issue > > + passt is launched as root, but can't open socket in passt dir. > > > > Obviously libvirt needs improvements too. > > But it seems like this is a defect as well. > > Thanks for the patch! I think it's absolutely unproblematic to keep > CAP_DAC_OVERRIDE for a moment at the beginning. Did you figure out > exactly why it's needed by the way? It's because the socket directory is chmod to qemu (by libvirt). Without CAP_DAC_OVERRIDE, root can't open/write to a non-root file/directory. Cole explains a bit more at the end of this comment: https://github.com/libguestfs/libguestfs/pull/218#issuecomment-3376943380 Rich. > > Signed-off-by: Cole Robinson > > Should we add: > > Link: https://github.com/libguestfs/libguestfs/pull/218 > > ? Or it's misleading, or you omitted it for any other reason? > > > --- > > isolation.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/isolation.c b/isolation.c > > index bbcd23b..b25f349 100644 > > --- a/isolation.c > > +++ b/isolation.c > > @@ -188,6 +188,9 @@ void isolate_initial(int argc, char **argv) > > * We have to keep CAP_SETUID and CAP_SETGID at this stage, so > > * that we can switch user away from root. > > * > > + * CAP_DAC_OVERRIDE may be required for socket setup when combined > > + * with --runas. > > + * > > * We have to keep some capabilities for the --netns-only case: > > * - CAP_SYS_ADMIN, so that we can setns() to the netns. > > * - Keep CAP_NET_ADMIN, so that we can configure interfaces > > @@ -198,7 +201,7 @@ void isolate_initial(int argc, char **argv) > > * isolate_prefork(). > > */ > > keep = BIT(CAP_NET_BIND_SERVICE) | BIT(CAP_SETUID) | BIT(CAP_SETGID) | > > - BIT(CAP_SYS_ADMIN) | BIT(CAP_NET_ADMIN); > > + BIT(CAP_SYS_ADMIN) | BIT(CAP_NET_ADMIN) | BIT(CAP_DAC_OVERRIDE); > > > > /* Since Linux 5.12, if we want to update /proc/self/uid_map to create > > * a mapping from UID 0, which only happens with pasta spawning a child > > -- > Stefano -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html