[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.16 05/31] virtio-net: Fix size check in dhclient workaround
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.16 05/31] virtio-net: Fix size check in dhclient workaround |
Date: |
Tue, 28 Jan 2025 00:40:57 +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 925a5c319e..204a80ec71 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1647,8 +1647,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-7.2.16 00/31] Patch Round-up for stable 7.2.16, freeze on 2025-02-06, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 01/31] hw/intc/openpic: Avoid taking address of out-of-bounds array index, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 02/31] bitops.h: Define bit operations on 'uint32_t' arrays, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 03/31] hw/intc/loongarch_extioi: Use set_bit32() and clear_bit32() for s->isr, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 04/31] cirrus-ci: Remove MSYS2 jobs duplicated with gitlab-ci, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 05/31] virtio-net: Fix size check in dhclient workaround,
Michael Tokarev <=
- [Stable-7.2.16 06/31] qdev: Fix set_pci_devfn() to visit option only once, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 07/31] ssh: Do not switch session to non-blocking mode, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 08/31] scsi: megasas: Internal cdbs have 16-byte length, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 09/31] tests/9p: fix Rreaddir response name, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 10/31] tests/9p: add missing Rgetattr response name, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 11/31] tests/9p: add 'use-after-unlink' test, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 12/31] 9pfs: remove obsolete comment in v9fs_getattr(), Michael Tokarev, 2025/01/28
- [Stable-7.2.16 14/31] tests/9p: also check 'Tgetattr' in 'use-after-unlink' test, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 15/31] target/ppc: Fix non-maskable interrupt while halted, Michael Tokarev, 2025/01/28
- [Stable-7.2.16 13/31] 9pfs: fix 'Tgetattr' after unlink, Michael Tokarev, 2025/01/28