Forward terminal window size to guest PTY #75
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
geomind_code/my_hypervisor!75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix_signals_resize"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#72
NOTE : This branch contains the changes of both #70 and #73
so either merge this only to development and close the parent PR ( #73 )
or merge this after parent PR gets merged
Sounds working, good job
Approved by mistake
The resize protocol works by sending a special 4-byte marker \x01RSZ followed by 4 bytes of size data through the same stream as normal terminal data.
The problem: if a user does something like cat /bin/some_binary or pipes binary data, and that binary data happens to contain the bytes 0x01, 0x52, 0x53, 0x5a somewhere, the guest parser will think it's a resize message. It will:
Swallow 8 bytes of real data (the 4 "magic" bytes + the next 4 bytes it thinks are rows/cols)
Resize the terminal to whatever garbage values those next 4 bytes decode to
The user sees corrupted output and their terminal may resize to something unusable. With only 4 bytes of magic
@ -6,0 +65,4 @@self.pos += 1;if self.pos == RESIZE_MSG_LEN {let rows = u16::from_be_bytes([self.buf[4], self.buf[5]]);let cols = u16::from_be_bytes([self.buf[6], self.buf[7]]);we should validate rows and cols to not be 0
@ -156,0 +250,4 @@fn test_resize_constants_match_protocol() {// These bytes must match encode_resize() output in my_hypervisor-lib/src/vsock/protocol.rs// If this test fails, the two crates have diverged.assert_eq!(RESIZE_MAGIC, [0x01, 0x52, 0x53, 0x5a]); // SOH + "RSZ"this will always pass even we changed the magic in protocol.rs
there is a corresponding test in protocol.rs that checks the same thing:
That way if either side changes the format, one of the two tests breaks.
but we can add dev-dependency so that tests can use the same constant
@rawdaGastan wrote in #75 (comment):
this is very low risk case because:
It's on the stdin direction, not stdout. The user would have to type or pipe the exact bytes 0x01 0x52 0x53 0x5a into their terminal input. Running cat /bin/some_binary produces output on stdout (guest → host), which is not parsed for resize markers
The only way binary data hits this path is if someone does something like
echo -e '\x01RSZ...' | chvm attach vm1orcat binary_file | chvm attach vm1which is an unusual edge caseso here are some suggestions if we do need to fix it:
what do you think?
@rawan wrote in #75 (comment):
we can document it