dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0001-tools-virtiofsd-Add-rseq-syscall-to-the-seccomp-allo.patch

Neal Gompa fdc9eb
From 7b223e38603de3a75602e14914d26f9d4baf52eb Mon Sep 17 00:00:00 2001
Neal Gompa fdc9eb
From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Neal Gompa fdc9eb
Date: Wed, 9 Feb 2022 12:14:56 +0100
Neal Gompa fdc9eb
Subject: [PATCH 1/2] tools/virtiofsd: Add rseq syscall to the seccomp
Neal Gompa fdc9eb
 allowlist
Neal Gompa fdc9eb
Neal Gompa fdc9eb
The virtiofsd currently crashes when used with glibc 2.35.
Neal Gompa fdc9eb
That is due to the rseq system call being added to every thread
Neal Gompa fdc9eb
creation [1][2].
Neal Gompa fdc9eb
Neal Gompa fdc9eb
[1]: https://www.efficios.com/blog/2019/02/08/linux-restartable-sequences/
Neal Gompa fdc9eb
[2]: https://sourceware.org/pipermail/libc-alpha/2022-February/136040.html
Neal Gompa fdc9eb
Neal Gompa fdc9eb
This happens not at daemon start, but when a guest connects
Neal Gompa fdc9eb
Neal Gompa fdc9eb
    /usr/lib/qemu/virtiofsd -f --socket-path=/tmp/testvfsd -o sandbox=chroot \
Neal Gompa fdc9eb
        -o source=/var/guests/j-virtiofs --socket-group=kvm
Neal Gompa fdc9eb
    virtio_session_mount: Waiting for vhost-user socket connection...
Neal Gompa fdc9eb
    # start ok, now guest will connect
Neal Gompa fdc9eb
    virtio_session_mount: Received vhost-user socket connection
Neal Gompa fdc9eb
    virtio_loop: Entry
Neal Gompa fdc9eb
    fv_queue_set_started: qidx=0 started=1
Neal Gompa fdc9eb
    fv_queue_set_started: qidx=1 started=1
Neal Gompa fdc9eb
    Bad system call (core dumped)
Neal Gompa fdc9eb
Neal Gompa fdc9eb
We have to put rseq on the seccomp allowlist to avoid that the daemon
Neal Gompa fdc9eb
is crashing in this case.
Neal Gompa fdc9eb
Neal Gompa fdc9eb
Reported-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Neal Gompa fdc9eb
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Neal Gompa fdc9eb
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Neal Gompa fdc9eb
Message-id: 20220209111456.3328420-1-christian.ehrhardt@canonical.com
Neal Gompa fdc9eb
Neal Gompa fdc9eb
[Moved rseq to its alphabetically ordered position in the seccomp
Neal Gompa fdc9eb
allowlist.
Neal Gompa fdc9eb
--Stefan]
Neal Gompa fdc9eb
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Neal Gompa fdc9eb
---
Neal Gompa fdc9eb
 tools/virtiofsd/passthrough_seccomp.c | 3 +++
Neal Gompa fdc9eb
 1 file changed, 3 insertions(+)
Neal Gompa fdc9eb
Neal Gompa fdc9eb
diff --git a/tools/virtiofsd/passthrough_seccomp.c b/tools/virtiofsd/passthrough_seccomp.c
Neal Gompa fdc9eb
index a3ce9f898d..2bc0127b69 100644
Neal Gompa fdc9eb
--- a/tools/virtiofsd/passthrough_seccomp.c
Neal Gompa fdc9eb
+++ b/tools/virtiofsd/passthrough_seccomp.c
Neal Gompa fdc9eb
@@ -91,6 +91,9 @@ static const int syscall_allowlist[] = {
Neal Gompa fdc9eb
     SCMP_SYS(renameat2),
Neal Gompa fdc9eb
     SCMP_SYS(removexattr),
Neal Gompa fdc9eb
     SCMP_SYS(restart_syscall),
Neal Gompa fdc9eb
+#ifdef __NR_rseq
Neal Gompa fdc9eb
+    SCMP_SYS(rseq), /* required since glibc 2.35 */
Neal Gompa fdc9eb
+#endif
Neal Gompa fdc9eb
     SCMP_SYS(rt_sigaction),
Neal Gompa fdc9eb
     SCMP_SYS(rt_sigprocmask),
Neal Gompa fdc9eb
     SCMP_SYS(rt_sigreturn),
Neal Gompa fdc9eb
-- 
Neal Gompa fdc9eb
2.35.1
Neal Gompa fdc9eb