public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH v2] isolation: keep CAP_DAC_OVERRIDE initially
@ 2025-10-08 15:01 Cole Robinson
  2025-10-09  8:14 ` Stefano Brivio
  0 siblings, 1 reply; 2+ messages in thread
From: Cole Robinson @ 2025-10-08 15:01 UTC (permalink / raw)
  To: passt-dev; +Cc: sbrivio, david, Cole Robinson

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
  + libvirt chowns /run/libvirt/qemu/passt 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 because CAP_DAC_OVERRIDE has been
  dropped, passt fails to create socket in qemu owned
  /run/libvirt/qemu/passt

Fix it by not dropping CAP_DAC_OVERRIDE in isolate_initial.

This might look sketchy, but isolate_initial already keeps
CAP_SYS_ADMIN and CAP_NET_ADMIN, so we are probably no worse off.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
v2: improve commit message

 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
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] isolation: keep CAP_DAC_OVERRIDE initially
  2025-10-08 15:01 [PATCH v2] isolation: keep CAP_DAC_OVERRIDE initially Cole Robinson
@ 2025-10-09  8:14 ` Stefano Brivio
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2025-10-09  8:14 UTC (permalink / raw)
  To: Cole Robinson; +Cc: passt-dev, david, Yumei Huang, Richard W.M. Jones

On Wed,  8 Oct 2025 11:01:33 -0400
Cole Robinson <crobinso@redhat.com> 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
>   + libvirt chowns /run/libvirt/qemu/passt 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 because CAP_DAC_OVERRIDE has been
>   dropped, passt fails to create socket in qemu owned
>   /run/libvirt/qemu/passt
> 
> Fix it by not dropping CAP_DAC_OVERRIDE in isolate_initial.
> 
> This might look sketchy, but isolate_initial already keeps
> CAP_SYS_ADMIN and CAP_NET_ADMIN, so we are probably no worse off.
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
> v2: improve commit message

Applied, thanks, and welcome to the git log!

-- 
Stefano


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-09  8:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-08 15:01 [PATCH v2] isolation: keep CAP_DAC_OVERRIDE initially Cole Robinson
2025-10-09  8:14 ` Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).