firecracker
firecracker copied to clipboard
Use `u32` to describe descriptor chain lengths
Description
Currently, parts of our virtio code use usize to describe the lengths of descriptor chains [1], while other parts use u32, which results in some ugly casts that can panic if a descriptor chain with length exceeding 2^32-1 bytes slips through validation somehow [2]. According to the virtio spec, descriptor chains can be at most 2^32-1 bytes long (as the "len" parameter in the used ring is a u32). We should thus use u32 instead of usize to describe these lengths, and upcast when interacting with non-virtio code that expects lengths to be usize.
Solution
- Change the len parameters in IoVecBuffer[Mut] to be u32
- Inside of the from_descriptor_chain functions, add validation that the total length does not overflow a u32, and return a new IoVecError variant if it does
hey i want to work in this issue do i need to make changes for IoVecBufferMut and IoVecBuffer both
Hey @BipulLamsal thanks for your interest in this. I think there was someone already working on this. Let me confirm with them and I will come back to you.