Skip to contentSkip to conversation

Linux xenfs vs privcmd

DISCUSSION Andrew Cooper 3 participants 6 messages Oct 8, 2025

lore
Share & tools
lore
#0 lore raw

Hello,

I'm doing a deployment of Xen on a remote system provisioned with Ubuntu 24.04, and I've found what I'm pretty sure is a bug.

In dom0, to start with:

user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     140 Oct  8 20:04 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 326 root root 0 Oct  8 20:04 ..

i.e. no /dev/xen/privcmd.

It turns out that mounting xenfs causes it to appear:

user@host:~$ sudo systemctl start proc-xen.mount
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
drwxr-xr-x   2 root root 0 Oct  8 20:05 .
dr-xr-xr-x 315 root root 0 Oct  8 20:04 ..
-r--r--r--   1 root root 0 Oct  8 20:05 capabilities
-rw-------   1 root root 0 Oct  8 20:05 privcmd
-rw-------   1 root root 0 Oct  8 20:05 xenbus
-r--------   1 root root 0 Oct  8 20:05 xensyms
-rw-------   1 root root 0 Oct  8 20:05 xsd_kva
-rw-------   1 root root 0 Oct  8 20:05 xsd_port

For good measure, I checked unmounting xenfs:

user@host:~$ sudo umount /proc/xen
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 291 root root 0 Oct  8 20:04 ..

and /dev/xen/privcmd stayed.

Anyway - /dev/xen/privcmd (and /hypercall) shouldn't be tied to xenfs. They should be SIF_PRIVILEGED alone, should they not?

~Andrew

#1 lore raw
Quoted 67 lines · Andrew Cooper

Hello,

I'm doing a deployment of Xen on a remote system provisioned with Ubuntu 24.04, and I've found what I'm pretty sure is a bug.

In dom0, to start with:

user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     140 Oct  8 20:04 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 326 root root 0 Oct  8 20:04 ..

i.e. no /dev/xen/privcmd.

It turns out that mounting xenfs causes it to appear:

user@host:~$ sudo systemctl start proc-xen.mount
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
drwxr-xr-x   2 root root 0 Oct  8 20:05 .
dr-xr-xr-x 315 root root 0 Oct  8 20:04 ..
(quoted diff) +0 -6
-r--r--r--   1 root root 0 Oct  8 20:05 capabilities
-rw-------   1 root root 0 Oct  8 20:05 privcmd
-rw-------   1 root root 0 Oct  8 20:05 xenbus
-r--------   1 root root 0 Oct  8 20:05 xensyms
-rw-------   1 root root 0 Oct  8 20:05 xsd_kva
-rw-------   1 root root 0 Oct  8 20:05 xsd_port

For good measure, I checked unmounting xenfs:

user@host:~$ sudo umount /proc/xen
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 291 root root 0 Oct  8 20:04 ..
Quoted 5 lines

and /dev/xen/privcmd stayed.

Anyway - /dev/xen/privcmd (and /hypercall) shouldn't be tied to xenfs. They should be SIF_PRIVILEGED alone, should they not?

Why would you want to restrict e.g. a Linux stubdom usermode from making hypercalls? Aiui this would break e.g. qemu running there. (Whether the tying to xenfs makes sense I can't really judge. Without that something else would need to make the two entries appear.)

Jan

#2 lore raw
Quoted 71 lines · Jan Beulich
Quoted 70 lines · Andrew Cooper

Hello,

I'm doing a deployment of Xen on a remote system provisioned with Ubuntu 24.04, and I've found what I'm pretty sure is a bug.

In dom0, to start with:

user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     140 Oct  8 20:04 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 326 root root 0 Oct  8 20:04 ..

i.e. no /dev/xen/privcmd.

It turns out that mounting xenfs causes it to appear:

user@host:~$ sudo systemctl start proc-xen.mount
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
drwxr-xr-x   2 root root 0 Oct  8 20:05 .
dr-xr-xr-x 315 root root 0 Oct  8 20:04 ..
(quoted diff) +0 -6
-r--r--r--   1 root root 0 Oct  8 20:05 capabilities
-rw-------   1 root root 0 Oct  8 20:05 privcmd
-rw-------   1 root root 0 Oct  8 20:05 xenbus
-r--------   1 root root 0 Oct  8 20:05 xensyms
-rw-------   1 root root 0 Oct  8 20:05 xsd_kva
-rw-------   1 root root 0 Oct  8 20:05 xsd_port

For good measure, I checked unmounting xenfs:

user@host:~$ sudo umount /proc/xen
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 291 root root 0 Oct  8 20:04 ..

and /dev/xen/privcmd stayed.

Quoted 6 lines
Quoted 2 lines

Anyway - /dev/xen/privcmd (and /hypercall) shouldn't be tied to xenfs. They should be SIF_PRIVILEGED alone, should they not?

Why would you want to restrict e.g. a Linux stubdom usermode from making hypercalls? Aiui this would break e.g. qemu running there. (Whether the tying to xenfs makes sense I can't really judge. Without that something else would need to make the two entries appear.)

Hmm, good point about Linux HVM stubdom.

It's no secret that I've been wanting to kill xenfs for several years now.  It's one best examples of the wrong tool for the job that's still around and causing bugs in the Xen ecosystem.

Either way, what I'm trying to say is that the contents of /dev/xen/ should be unrelated to xenfs.

~Andrew

#3 lore raw
In reply to Andrew Cooper
Quoted 67 lines · Andrew Cooper

Hello,

I'm doing a deployment of Xen on a remote system provisioned with Ubuntu 24.04, and I've found what I'm pretty sure is a bug.

In dom0, to start with:

user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     140 Oct  8 20:04 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 326 root root 0 Oct  8 20:04 ..

i.e. no /dev/xen/privcmd.

It turns out that mounting xenfs causes it to appear:

user@host:~$ sudo systemctl start proc-xen.mount
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
drwxr-xr-x   2 root root 0 Oct  8 20:05 .
dr-xr-xr-x 315 root root 0 Oct  8 20:04 ..
(quoted diff) +0 -6
-r--r--r--   1 root root 0 Oct  8 20:05 capabilities
-rw-------   1 root root 0 Oct  8 20:05 privcmd
-rw-------   1 root root 0 Oct  8 20:05 xenbus
-r--------   1 root root 0 Oct  8 20:05 xensyms
-rw-------   1 root root 0 Oct  8 20:05 xsd_kva
-rw-------   1 root root 0 Oct  8 20:05 xsd_port

For good measure, I checked unmounting xenfs:

user@host:~$ sudo umount /proc/xen
user@host:~$ ls -la /dev/xen/
total 0
drwxr-xr-x  2 root root     180 Oct  8 20:05 .
drwxr-xr-x 18 root root    4620 Oct  8 20:04 ..
crw-------  1 root root 10, 120 Oct  8 20:04 evtchn
crw-------  1 root root 10, 118 Oct  8 20:04 gntalloc
crw-------  1 root root 10, 119 Oct  8 20:04 gntdev
crw-------  1 root root 10, 115 Oct  8 20:05 hypercall
crw-------  1 root root 10, 116 Oct  8 20:05 privcmd
crw-------  1 root root 10, 124 Oct  8 20:04 xenbus
crw-------  1 root root 10, 123 Oct  8 20:04 xenbus_backend
user@host:~$ ls -la /proc/xen/
total 0
dr-xr-xr-x   2 root root 0 Oct  8 20:04 .
dr-xr-xr-x 291 root root 0 Oct  8 20:04 ..
Quoted 5 lines

and /dev/xen/privcmd stayed.

Anyway - /dev/xen/privcmd (and /hypercall) shouldn't be tied to xenfs. They should be SIF_PRIVILEGED alone, should they not?

I don't think they should be tied to SIF_PRIVILEGED, as device model ops are handled via the privcmd driver, too.

TBH I have no idea why there is a direct connection to xenfs.

Did you try to modprobe privcmd without mounting xenfs? I guess the connection is that the capabilities in /proc/xen/capabilities are tested to contain "control_d", resulting in the privcmd driver to be loaded.

Juergen

#4 lore raw
Quoted 7 lines · Jürgen Groß
Quoted 2 lines · Andrew Cooper

Anyway - /dev/xen/privcmd (and /hypercall) shouldn't be tied to xenfs. They should be SIF_PRIVILEGED alone, should they not?

I don't think they should be tied to SIF_PRIVILEGED, as device model ops are handled via the privcmd driver, too.

Quoted 6 lines

TBH I have no idea why there is a direct connection to xenfs.

Did you try to modprobe privcmd without mounting xenfs? I guess the connection is that the capabilities in /proc/xen/capabilities are tested to
contain "control_d", resulting in the privcmd driver to be loaded.

modprobe xen_privcmd in isolation does cause /dev/xen/privcmd to appear.

~Andrew

#5 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Jürgen Groß
Quoted 2 lines · Andrew Cooper

Anyway - /dev/xen/privcmd (and /hypercall) shouldn't be tied to xenfs. They should be SIF_PRIVILEGED alone, should they not?

I don't think they should be tied to SIF_PRIVILEGED, as device model ops are handled via the privcmd driver, too.

Quoted 8 lines
Quoted 6 lines

TBH I have no idea why there is a direct connection to xenfs.

Did you try to modprobe privcmd without mounting xenfs? I guess the connection is that the capabilities in /proc/xen/capabilities are tested to
contain "control_d", resulting in the privcmd driver to be loaded.

modprobe xen_privcmd in isolation does cause /dev/xen/privcmd to appear.

Yes, I expected that.

So for removing xenfs there needs to be a way to find out that the system is a Xen dom0. The easiest way would be to look into /sys/hypervisor/type to contain "xen" and then /sys/hypervisor/start_flags/privileged to contain "1".

Juergen