Skip to content

drivers(xenstore): don't deliver user replies under msgbuffer_mutex - #118

Merged
bleggett merged 1 commit into
edera/mainlinefrom
bleggett/fix-xenbus-deadlock
Nov 19, 2026
Merged

bleggett merged 1 commit into
edera/mainlinefrom
bleggett/fix-xenbus-deadlock

Conversation

@bleggett

@bleggett bleggett commented Nov 18, 2026 •

Copy link
Copy Markdown

Found this in some random e2e failures that happened after I added some xenstore restart tests.

See attached sysrq stack captured during the hang.

guest-sysrq-w.txt

Seems like the guest kernel's xenbus thread is stuck waiting for a lock, so no xenstore replies reach the guest after this point.

The lock involved, from what I can tell, is u->msgbuffer_mutex in drivers/xen/xenbus/xenbus_dev_frontend.c:

  • xenbus_file_write takes the lock (line 574). For an UNWATCH it keeps the lock while it waits for the xenstored
    reply (unregister_xenbus_watch at line 535 -> xs_talkv).
  • xenbus_dev_queue_reply takes the same lock (line 372). The xenbus thread calls it to deliver the reply of an
    earlier request on the same fd.

So if a fd still has a request waiting for its reply when it gets an UNWATCH, the UNWATCH holds the lock and waits for the xenbus thread. The xenbus thread waits for the lock, and at this point the whole guest xenstore connection stops.

Submitted upstream: https://lore.kernel.org/lkml/20261118-bleggett-xenbus-transactions-mutex-v1-1-6669e3f54955@edera.io/

@bleggett bleggett changed the title drivers(xenstored): xenbus_write_watch: do not hold msgbuffer_mutex across synchronous register calls drivers(xenstore): xenbus_write_watch: do not hold msgbuffer_mutex across synchronous register calls Nov 18, 2026
@bleggett bleggett changed the title drivers(xenstore): xenbus_write_watch: do not hold msgbuffer_mutex across synchronous register calls drivers(xenstore): don't deliver user replies under msgbuffer_mutex Nov 18, 2026
@bleggett
bleggett merged commit cc5c660 into edera/mainline Nov 19, 2026
3 checks passed
@github-actions

Copy link
Copy Markdown

Backport to edera/6.18-lts: proposed in #122

Checks and builds passed.

Run log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants