hermit-os / uhyve

A specialized hypervisor for Hermit.
Apache License 2.0
258 stars 29 forks source link

GDB Protocol is not handled correctly #630

Open jounathaen opened 10 months ago

jounathaen commented 10 months ago

When I run cargo test gdb on the main branch and add a print to the read_addrs function, https://github.com/hermit-os/uhyve/blob/dc6b01e1294f610af309be44cbdb91c9e623b944/src/linux/gdb/mod.rs#L121 I get the following reads:

[...]
>>>  reading start_addr 0x59d478
>>>  reading start_addr 0x64412074656e726d
>>>  reading start_addr 0x64412074656e7265
>>>  reading start_addr 0x64412074656e7265
>>>  reading start_addr 0x64412074656e726d
>>>  reading start_addr 0x3f8000
>>>  reading start_addr 0x0
>>>  reading start_addr 0x99d478
>>>  reading start_addr 0x99d478
>>>  reading start_addr 0x99d478
>>>  reading start_addr 0x649a84
[...]

0x64412074656e726d is definitely not a valid virtual address on x86. Currently, this fails silently, as the virt_to_phys() maps this address to the address 26d.

-> We should check, whether this is valid memory and return an Error if not (read_addr API as reference: https://docs.rs/gdbstub/latest/gdbstub/target/ext/base/singlethread/trait.SingleThreadBase.html#tymethod.read_addrs)

jounathaen commented 10 months ago

This is partly fixed in https://github.com/hermit-os/uhyve/pull/527, where this access returns an error to gdbstub. However, I'm still not sure why this address is accessed at all?