]> 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>
Tue, 14 Dec 2021 14:56:31 +0000 (08:56 -0600)
commit9e41f16fca436a666ee79f5219797a2c58b6cf19
treef8326efcf1d01427028a7697d5815251b5e8fcc9
parent3054f772de9c2e97e7c196d4f3e70d58aca1e807
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