[SLOF] [PATCH 1/3] virtio-serial: Fix invalid stack access with closed virtio device
Jordan Niethe
jniethe5 at gmail.com
Mon Aug 28 11:37:34 AEST 2023
When virtiodev is 0, its read method accesses beyond the end of the
stack with nip. Instead finish with 1 on the stack to mirror the
virtio-serial-getchar case and the behavior of the write method to
return successfully even with the virtio device closed.
Fixes: 8174acd ("virtio-serial: Close device completely")
Co-developed-by: Kautuk Consul <kconsul at linux.vnet.ibm.com>
Signed-off-by: Kautuk Consul <kconsul at linux.vnet.ibm.com>
Signed-off-by: Jordan Niethe <jniethe5 at gmail.com>
---
board-qemu/slof/virtio-serial.fs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs
index 82868e2..a67a310 100644
--- a/board-qemu/slof/virtio-serial.fs
+++ b/board-qemu/slof/virtio-serial.fs
@@ -78,7 +78,7 @@ virtiodev virtio-serial-init drop
: read ( addr len -- actual )
0= IF drop 0 EXIT THEN
- virtiodev 0= IF nip EXIT THEN
+ virtiodev 0= IF drop 1 EXIT THEN
virtiodev virtio-serial-haschar 0= IF 0 swap c! -2 EXIT THEN
virtiodev virtio-serial-getchar swap c! 1
;
--
2.39.3
More information about the SLOF
mailing list