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 <rbradford@meta.com>
Assisted-by: Claude:claude-opus-4-6
This commit is contained in:
Rob Bradford
2026-05-06 15:07:54 +01:00
parent fe7745b472
commit 521b15bda6

View File

@@ -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::<Vec<u8>>();