From 3fc0ff00d50caab60566c17f2ef6fff19f686ba9 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Fri, 24 Apr 2026 17:14:17 -0700 Subject: [PATCH] vhost_user_block: fix process_queue unwraps process_queue() unwrapped four guest-reachable Results. Convert each unwrap to a logged error path. A failed status write is demoted to len = 0 so the head is still retired via add_used; an add_used failure breaks the batch (queue is in a bad state); a needs_notification failure signals; a signal failure is logged. The daemon stays up. Signed-off-by: Dylan Reid --- vhost_user_block/src/lib.rs | 59 ++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index 8d4109678..cc6ace69b 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -141,11 +141,16 @@ impl VhostUserBlkThread { Ok(l) => (VIRTIO_BLK_S_OK as u8, l + 1), Err(e) => (e.status(), 1), }; - desc_chain - .memory() - .write_obj(status, request.status_addr()) - .unwrap(); - len + + if let Err(e) = desc_chain.memory().write_obj(status, request.status_addr()) { + warn!( + "vhost-user-blk: failed to write status to 0x{:x}: {e:?}", + request.status_addr().0 + ); + 0 + } else { + len + } } Err(err) => { error!("failed to parse available descriptor chain: {err:?}"); @@ -153,32 +158,44 @@ impl VhostUserBlkThread { } }; - vring - .get_queue_mut() - .add_used(desc_chain.memory(), desc_chain.head_index(), len) - .unwrap(); + if let Err(e) = + vring + .get_queue_mut() + .add_used(desc_chain.memory(), desc_chain.head_index(), len) + { + error!("vhost-user-blk: add_used failed: {e:?}"); + // Stop processing this batch — the queue is in a bad state. + break; + } used_descs = true; } - let mut needs_signalling = false; - if self.event_idx { - if vring + let needs_signalling = if self.event_idx { + match vring .get_queue_mut() .needs_notification(self.mem.memory().deref()) - .unwrap() { - debug!("signalling queue"); - needs_signalling = true; - } else { - debug!("omitting signal (event_idx)"); + Ok(true) => { + debug!("signalling queue"); + true + } + Ok(false) => { + debug!("omitting signal (event_idx)"); + false + } + Err(e) => { + error!("vhost-user-blk: needs_notification failed: {e:?}"); + // Just signal — the guest can re-check. + true + } } } else { debug!("signalling queue"); - needs_signalling = true; - } + true + }; - if needs_signalling { - vring.signal_used_queue().unwrap(); + if needs_signalling && let Err(e) = vring.signal_used_queue() { + error!("vhost-user-blk: signal_used_queue failed: {e:?}"); } used_descs