]> git.ipfire.org Git - thirdparty/qemu.git/commit
virtio-net: fix use after unmap/free for sg
authorJason Wang <jasowang@redhat.com>
Thu, 2 Sep 2021 05:44:12 +0000 (13:44 +0800)
committerMichael Roth <michael.roth@amd.com>
Fri, 15 Oct 2021 22:48:28 +0000 (17:48 -0500)
commit5881d76ff41ab898751babdf26ea668cb8fb7a0e
treed27b21c8fc276037211fd2d66b1c9583ebb8d7d8
parent2ae61d81a575d22599fb22355acc995def2902fc
virtio-net: fix use after unmap/free for sg

When mergeable buffer is enabled, we try to set the num_buffers after
the virtqueue elem has been unmapped. This will lead several issues,
E.g a use after free when the descriptor has an address which belongs
to the non direct access region. In this case we use bounce buffer
that is allocated during address_space_map() and freed during
address_space_unmap().

Fixing this by storing the elems temporarily in an array and delay the
unmap after we set the the num_buffers.

This addresses CVE-2021-3748.

Reported-by: Alexander Bulekov <alxndr@bu.edu>
Fixes: fbe78f4f55c6 ("virtio-net support")
Cc: qemu-stable@nongnu.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit bedd7e93d01961fcb16a97ae45d93acf357e11f6)
Signed-off-by: Michael Roth <michael.roth@amd.com>
hw/net/virtio-net.c