* [PATCH] xen/pvcalls: return -EINTR from recvmsg when the wait is interrupted
@ 2026-11-18 14:53 Suyuan Wang via B4 Relay
0 siblings, 0 replies; only message in thread
From: Suyuan Wang via B4 Relay @ 2026-11-18 14:53 UTC (permalink / raw)
To: sstabellini, jgross; +Cc: oleksandr_tyshchenko, xen-devel, linux-kernel
From: Suyuan Wang <stevewong@hust.edu.cn>
pvcalls_front_recvmsg() waits for data in a loop and ignores what
wait_event_interruptible() returns:
while (!(flags & MSG_DONTWAIT) && !pvcalls_front_read_todo(map)) {
wait_event_interruptible(map->active.inflight_conn_req,
pvcalls_front_read_todo(map));
}
Once a signal is pending, wait_event_interruptible() returns
-ERESTARTSYS right away without sleeping, and the loop calls it again.
The caller then spins with map->active.in_mutex held until data arrives
or the backend reports an error. The signal can't be handled while it
spins, so the task can't be killed either, and other readers of the
socket block on in_mutex.
Return -EINTR when the wait is interrupted, as pvcalls_front_accept()
already does for its interruptible waits. Jump to the end of the
function so that in_mutex is released and pvcalls_exit_sock() is
called.
Found with a static analysis tool and checked by hand.
Fixes: ae0d04052e07 ("xen/pvcalls: implement recvmsg")
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
There are no in-tree callers of pvcalls_front_recvmsg(), so this only
matters to code built on the exported frontend API. That's why I left
out Cc: stable.
Compile tested only (x86_64 with CONFIG_XEN_PVCALLS_FRONTEND=y, W=1 and
sparse show no new warnings). I haven't run it in a Xen guest.
---
drivers/xen/pvcalls-front.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
index 3e7aa807c317..5d6c8ba66849 100644
--- a/drivers/xen/pvcalls-front.c
+++ b/drivers/xen/pvcalls-front.c
@@ -693,8 +693,11 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
len = XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER);
while (!(flags & MSG_DONTWAIT) && !pvcalls_front_read_todo(map)) {
- wait_event_interruptible(map->active.inflight_conn_req,
- pvcalls_front_read_todo(map));
+ if (wait_event_interruptible(map->active.inflight_conn_req,
+ pvcalls_front_read_todo(map))) {
+ ret = -EINTR;
+ goto out;
+ }
}
ret = __read_ring(map->active.ring, &map->active.data,
&msg->msg_iter, len, flags);
@@ -706,6 +709,7 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
if (ret == -ENOTCONN)
ret = 0;
+out:
mutex_unlock(&map->active.in_mutex);
pvcalls_exit_sock(sock);
return ret;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 14:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 14:53 [PATCH] xen/pvcalls: return -EINTR from recvmsg when the wait is interrupted Suyuan Wang via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®