From aee4fd6010a779a3724040e6f2460df27baa11ee Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 6 May 2026 12:51:57 +0100 Subject: [PATCH] virtio-devices: rng: Skip device-readable descriptors A device-readable descriptor anywhere in the chain caused the handler to reset the byte count to zero and abandon the rest of the chain. This discards valid device-writable descriptors that follow and misreports bytes already written to earlier descriptors. Skip device-readable and zero-length descriptors individually so the remaining device-writable buffers still get filled with entropy. Signed-off-by: Rob Bradford Assisted-by: Claude:claude-opus-4-6 --- virtio-devices/src/rng.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/virtio-devices/src/rng.rs b/virtio-devices/src/rng.rs index df596813b..8040913de 100644 --- a/virtio-devices/src/rng.rs +++ b/virtio-devices/src/rng.rs @@ -64,14 +64,12 @@ impl RngEpollHandler { // report a used length of 0 to indicate failure. let mut total_len: usize = 0; while let Some(desc) = desc_chain.next() { - if !desc.is_write_only() || desc.len() == 0 { - warn!( - "Skipping descriptor with write_only={} len={}", - desc.is_write_only(), - desc.len() - ); - total_len = 0; - break; + if !desc.is_write_only() { + warn!("Skipping device-readable descriptor"); + continue; + } + if desc.len() == 0 { + continue; } let addr = match desc .addr()