Peter Maydell
32f1c201ee
hw/misc/bcm2835_property: Avoid overflow in OTP access properties
...
Coverity points out that in our handling of the property
RPI_FWREQ_SET_CUSTOMER_OTP we have a potential overflow. This
happens because we read start_num and number from the guest as
unsigned 32 bit integers, but then the variable 'n' we use as a loop
counter as we iterate from start_num to start_num + number is only an
"int". That means that if the guest passes us a very large start_num
we will interpret it as negative. This will result in an assertion
failure inside bcm2835_otp_set_row(), which checks that we didn't
pass it an invalid row number.
A similar issue applies to all the properties for accessing OTP rows
where we are iterating through with a start and length read from the
guest.
Use uint32_t for the loop counter to avoid this problem. Because in
all cases 'n' is only used as a loop counter, we can do this as
part of the for(), restricting its scope to exactly where we need it.
Resolves: Coverity CID 1549401
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20240723131029.1159908-3-peter.maydell@linaro.org
2024-07-29 16:55:59 +01:00
..
2024-04-25 10:21:06 +01:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-04-25 12:48:12 +02:00
2021-02-11 11:50:14 +00:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2021-03-08 11:54:16 +00:00
2023-12-30 07:38:06 +11:00
2021-09-01 11:08:18 +01:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2022-06-30 09:21:14 +02:00
2023-12-30 07:38:06 +11:00
2024-06-16 21:08:54 +02:00
2024-07-02 07:52:43 +02:00
2024-06-16 21:08:54 +02:00
2023-12-30 07:38:06 +11:00
2023-01-18 11:14:34 +01:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-07-29 16:55:59 +01:00
2023-12-30 07:38:06 +11:00
2024-07-11 11:41:33 +01:00
2022-10-22 23:15:40 +02:00
2024-06-04 11:53:43 +02:00
2024-04-25 10:21:06 +01:00
2023-12-30 07:38:06 +11:00
2024-07-02 06:58:48 +02:00
2020-09-18 14:12:32 -04:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-06-21 16:20:45 +01:00
2022-08-08 23:43:11 +02:00
2023-10-12 14:11:44 +02:00
2024-04-25 12:48:12 +02:00
2024-04-25 12:48:12 +02:00
2024-04-25 12:48:12 +02:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-04-25 12:48:12 +02:00
2024-04-25 12:48:12 +02:00
2024-04-25 12:48:12 +02:00
2021-05-02 17:24:50 +02:00
2023-12-30 07:38:06 +11:00
2024-04-25 10:21:06 +01:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2021-03-08 17:20:01 +00:00
2024-03-11 22:10:18 +01:00
2024-03-05 13:22:55 +00:00
2024-02-11 13:20:23 +01:00
2023-12-30 07:38:06 +11:00
2024-04-25 10:21:06 +01:00
2021-05-02 17:24:50 +02:00
2023-01-06 10:42:55 +10:00
2023-01-06 10:42:55 +10:00
2024-06-16 21:08:54 +02:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-02-15 15:53:12 +01:00
2024-04-25 10:21:06 +01:00
2023-12-30 07:38:06 +11:00
2024-02-15 14:32:38 +00:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-01-12 17:15:09 +00:00
2023-01-12 17:15:09 +00:00
2023-01-12 17:15:09 +00:00
2023-01-12 17:15:09 +00:00
2020-09-18 14:12:32 -04:00
2023-10-25 17:35:15 +02:00
2024-07-01 17:16:04 -04:00
2024-07-01 17:16:04 -04:00
2024-07-01 17:16:04 -04:00
2023-01-12 17:15:09 +00:00
2023-07-10 22:29:14 +10:00
2021-05-02 17:24:50 +02:00
2023-10-12 12:34:30 +10:00
2023-01-26 13:25:07 +01:00
2020-09-09 15:54:19 -07:00
2023-12-30 07:38:06 +11:00
2023-09-21 11:31:16 +03:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2024-07-11 11:41:34 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-06-16 21:08:54 +02:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2020-08-28 10:02:46 +01:00
2023-12-30 07:38:06 +11:00
2023-12-30 07:38:06 +11:00
2023-09-08 16:41:34 +01:00
2024-04-25 10:21:06 +01:00
2023-12-30 07:38:06 +11:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-04-25 10:21:06 +01:00
2024-07-01 15:40:54 +01:00