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 <rbradford@meta.com>
Assisted-by: Claude:claude-opus-4-6
This commit is contained in:
Rob Bradford
2026-05-06 12:51:57 +01:00
parent f0bb79a3a9
commit aee4fd6010

View File

@@ -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()