aboutsummaryrefslogtreecommitdiff
path: root/rust/qemu-api/src
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2025-02-28 19:16:51 +0000
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-03-11 20:03:24 +0100
commit700d3d6dd41de3bd3f1153e3cfe00b93f99b1441 (patch)
tree3d1b897f12a6b165533277cf540e8d3106f89307 /rust/qemu-api/src
parente21fe8fb15e70dd8110fd5530521a2e41dc2c201 (diff)
downloadqemu-700d3d6dd41de3bd3f1153e3cfe00b93f99b1441.zip
qemu-700d3d6dd41de3bd3f1153e3cfe00b93f99b1441.tar.gz
qemu-700d3d6dd41de3bd3f1153e3cfe00b93f99b1441.tar.bz2
hw/net/smc91c111: Don't allow data register access to overrun buffer
For accesses to the 91c111 data register, the address within the packet's data frame is determined by a combination of the pointer register and the offset used to access the data register, so that you can access data at effectively wider than byte width. The pointer register's pointer field is 11 bits wide, which is exactly the size to index a 2048-byte data frame. We weren't quite getting the logic right for ensuring that we end up with a pointer value to use in the s->data[][] array that isn't out of bounds: * we correctly mask when getting the initial pointer value * for the "autoincrement the pointer register" case, we correctly mask after adding 1 so that the pointer register wraps back around at the 2048 byte mark * but for the non-autoincrement case where we have to add the low 2 bits of the data register offset, we don't account for the possibility that the pointer register is 0x7ff and the addition should wrap Fix this bug by factoring out the "get the p value to use as an array index" into a function, making it use FIELD macro names rather than hard-coded constants, and having a utility function that does "add a value and wrap it" that we can use both for the "autoincrement" and "add the offset bits" codepaths. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2758 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20250228191652.1957208-1-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'rust/qemu-api/src')
0 files changed, 0 insertions, 0 deletions