tokio-rs / io-uring

The `io_uring` library for Rust
Apache License 2.0
1.16k stars 129 forks source link

Fix broken RecvMsgOut parsing #257

Closed SUPERCILEX closed 7 months ago

SUPERCILEX commented 7 months ago

The current parsing doesn't actually let the buffer ever be truncated and instead errors out immediately. This PR fixes it to only ever out when the buffer is smaller than the header. This implementation matches liburing's validation: https://github.com/axboe/liburing/blob/c44319a6bfb9953b430325227a94136690c19c33/src/include/liburing.h#L831-L834

quininer commented 7 months ago

This looks good, is there a regression test possible?

SUPERCILEX commented 7 months ago

I added a test, but it's pretty terrible as I didn't want to deal with cancelling the recvmulti to change its header length or add ancillary data. That said, it does at least test for payload and namelen truncation.

SUPERCILEX commented 7 months ago

@quininer any chance you can run the test on your machine? It works fine on mine, so I'm not sure what's going on in CI. Maybe old kernels didn't set the trunc flag?

quininer commented 7 months ago

You can try check some flag to skip it on ci.

SUPERCILEX commented 7 months ago

Sounds good, I added a kernel version check for 6.6 (which is what I'm running), but it might work on earlier kernels.

quininer commented 7 months ago

maybe you are interested review this @lucab :)

SUPERCILEX commented 7 months ago

Ok, I think I addressed all the feedback, so should be ready for another round!

quininer commented 7 months ago

Thank you!