]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/net/smc91c111: Sanitize packet length on tx
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 28 Feb 2025 17:48:00 +0000 (17:48 +0000)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 18 Mar 2025 06:02:48 +0000 (09:02 +0300)
commite8fd97fc1e5062798cbb586eaacd21c7894a7890
tree1a8069327f9c464af7fb4847c40b8467a4855496
parente9f6c32339038787a3535969456bab021ec31200
hw/net/smc91c111: Sanitize packet length on tx

When the smc91c111 transmits a packet, it must read a control byte
which is at the end of the data area and CRC.  However, we don't
sanitize the length field in the packet buffer, so if the guest sets
the length field to something large we will try to read past the end
of the packet data buffer when we access the control byte.

As usual, the datasheet says nothing about the behaviour of the
hardware if the guest misprograms it in this way.  It says only that
the maximum valid length is 2048 bytes.  We choose to log the guest
error and silently drop the packet.

This requires us to factor out the "mark the tx packet as complete"
logic, so we can call it for this "drop packet" case as well as at
the end of the loop when we send a valid packet.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2742
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250228174802.1945417-3-peter.maydell@linaro.org>
[PMD: Update smc91c111_do_tx() as len > MAX_PACKET_SIZE]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit aad6f264add3f2be72acb660816588fe09110069)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/net/smc91c111.c