]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/net/smc91c111: Sanitize packet numbers
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 28 Feb 2025 17:47:59 +0000 (17:47 +0000)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 11 Mar 2025 19:01:27 +0000 (20:01 +0100)
commit2fa3a5b9469615d06091cf473d172794148e1248
tree4bf93381adb05ea5e769cb4db1bbee3e2e57fc3f
parent822405b1fea4f0f404df418bd70da0588b9207ce
hw/net/smc91c111: Sanitize packet numbers

The smc91c111 uses packet numbers as an index into its internal
s->data[][] array. Valid packet numbers are between 0 and 3, but
the code does not generally check this, and there are various
places where the guest can hand us an arbitrary packet number
and cause an out-of-bounds access to the data array.

Add validation of packet numbers. The datasheet is not very
helpful about how guest errors like this should be handled:
it says nothing on the subject, and none of the documented
error conditions are relevant. We choose to log the situation
with LOG_GUEST_ERROR and silently ignore the attempted operation.

In the places where we are about to access the data[][] array
using a packet number and we know the number is valid because
we got it from somewhere that has already validated, we add
an assert() to document that belief.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250228174802.1945417-2-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/net/smc91c111.c