From 521b15bda687588bd0598a0ecbe7ce3c235d031d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 6 May 2026 15:07:54 +0100 Subject: [PATCH] virtio-devices: console: Skip device-readable descriptors in input queue The input queue handler wrote data to every descriptor without checking the write-only flag. The device must not write to device-readable buffers. Skip them with a warning. Signed-off-by: Rob Bradford Assisted-by: Claude:claude-opus-4-6 --- virtio-devices/src/console.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/virtio-devices/src/console.rs b/virtio-devices/src/console.rs index c66b37532..2abf44639 100644 --- a/virtio-devices/src/console.rs +++ b/virtio-devices/src/console.rs @@ -12,7 +12,7 @@ use std::{cmp, io, result}; use anyhow::anyhow; use event_monitor::event; use libc::{EFD_NONBLOCK, TIOCGWINSZ}; -use log::{error, info}; +use log::{error, info, warn}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use serial_buffer::SerialBuffer; @@ -213,6 +213,10 @@ impl ConsoleEpollHandler { if in_buffer.is_empty() { break; } + if !desc.is_write_only() { + warn!("Skipping device-readable descriptor on receiveq"); + continue; + } let len = cmp::min(desc.len(), in_buffer.len() as u32); let source_slice = in_buffer.drain(..len as usize).collect::>();