[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.1.3 05/58] virtio-net: Fix size check in dhclient workaround
From: |
Michael Tokarev |
Subject: |
[Stable-9.1.3 05/58] virtio-net: Fix size check in dhclient workaround |
Date: |
Mon, 27 Jan 2025 23:24:51 +0300 |
work_around_broken_dhclient() accesses IP and UDP headers to detect
relevant packets and to calculate checksums, but it didn't check if
the packet has size sufficient to accommodate them, causing out-of-bound
access hazards. Fix this by correcting the size requirement.
Fixes: 1d41b0c1ec66 ("Work around dhclient brokenness")
Cc: qemu-stable@nongnu.org
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit a8575f7fb2f213e6690b23160b04271d47fdfaa8)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index ed33a32877..cf27d5cbe5 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1692,8 +1692,11 @@ static void virtio_net_hdr_swap(VirtIODevice *vdev,
struct virtio_net_hdr *hdr)
static void work_around_broken_dhclient(struct virtio_net_hdr *hdr,
uint8_t *buf, size_t size)
{
+ size_t csum_size = ETH_HLEN + sizeof(struct ip_header) +
+ sizeof(struct udp_header);
+
if ((hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && /* missing csum */
- (size > 27 && size < 1500) && /* normal sized MTU */
+ (size >= csum_size && size < 1500) && /* normal sized MTU */
(buf[12] == 0x08 && buf[13] == 0x00) && /* ethertype == IPv4 */
(buf[23] == 17) && /* ip.protocol == UDP */
(buf[34] == 0 && buf[35] == 67)) { /* udp.srcport == bootps */
--
2.39.5
- [Stable-9.1.3 00/58] Patch Round-up for stable 9.1.3, freeze on 2025-02-06, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 02/58] bitops.h: Define bit operations on 'uint32_t' arrays, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 03/58] hw/intc/loongarch_extioi: Use set_bit32() and clear_bit32() for s->isr, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 04/58] linux-user: Fix strace output for s390x mmap(), Michael Tokarev, 2025/01/28
- [Stable-9.1.3 01/58] hw/intc/openpic: Avoid taking address of out-of-bounds array index, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 09/58] migration: Allow pipes to keep working for fd migrations, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 05/58] virtio-net: Fix size check in dhclient workaround,
Michael Tokarev <=
- [Stable-9.1.3 06/58] qdev: Fix set_pci_devfn() to visit option only once, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 07/58] ssh: Do not switch session to non-blocking mode, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 08/58] plugins: add missing export for qemu_plugin_num_vcpus, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 10/58] virtio-net: Add queues before loading them, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 11/58] ppc/spapr: fix drc index mismatch for partially enabled vcpus, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 12/58] scsi: megasas: Internal cdbs have 16-byte length, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 13/58] tests/9p: fix Rreaddir response name, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 14/58] tests/9p: add missing Rgetattr response name, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 16/58] 9pfs: remove obsolete comment in v9fs_getattr(), Michael Tokarev, 2025/01/28
- [Stable-9.1.3 15/58] tests/9p: add 'use-after-unlink' test, Michael Tokarev, 2025/01/28