Re: [PATCH] net/9p: Fix uaf / refcnt underflow for req object in virtio

From: Christian Schoenebeck
Date: Mon Jul 22 2024 - 04:38:48 EST


On Monday, July 22, 2024 8:59:21 AM CEST asmadeus@xxxxxxxxxxxxx wrote:
[...]
> If the request really was cancelled we'll get the flush reply before the
> response and that'll drop the second ref in the cancelled callback,
> which would also blow up, but afaik qemu doesn't implement this so this
> code path so this was never tested.

It is implemented in QEMU 9p server according to the 9p protocol specs:
http://ericvh.github.io/9p-rfc/rfc9p2000.html#anchor28

So a Tflush request by client is immediately answered by a Rflush response and
in this case no answer is sent to the original request being flushed.

There are also QEMU test cases guarding the expected Tflush behaviour:
https://github.com/qemu/qemu/blob/a7ddb48b/tests/qtest/virtio-9p-test.c#L403
and
https://github.com/qemu/qemu/blob/a7ddb48b/tests/qtest/virtio-9p-test.c#L444

The 2nd test case handles the behaviour when the Tflush request arrived too
late, after the original request already completed successfully that is. So in
this case client first receives a success response to the original request,
then followed by Rflush response.

/Christian