Solo5 / solo5

A sandboxed execution environment for unikernels
ISC License
883 stars 136 forks source link

xen console: update the "to be written" count #538

Closed palainp closed 1 year ago

palainp commented 1 year ago

Previously we can get an infinite loop as written is the number of bytes written to the console returned by console_write_some (from 0 to its len argument) (l111), then it's compared against len for teminating the loop (l126).

The issue is that if len is greater than the Xen buffer size (2048B), we have to loop over the buffer and use console_write_some more than one time (and it will return something in the interval [0,len-written[ which will never equals len (l126).

The proposed patch lower the len which will stand for "how many bytes I still have to write", and stops the loop when it comes to 0 increase the written count until it reaches len. This fix https://github.com/Solo5/solo5/issues/537.

hannesm commented 1 year ago

looks fine to me, a regression test could be added here in the solo5 test suite (the behaviour should be reproducible without any mirageos / ocaml involved).

dinosaure commented 1 year ago

Thanks, the test is done by @hannesm, I will cut a release.