Nicolas Iooss
8f8c04bf1e
i2c: fix stack buffer overflow vulnerability in i2c md command
...
When running "i2c md 0 0 80000100", the function do_i2c_md parses the
length into an unsigned int variable named length. The value is then
moved to a signed variable:
int nbytes = length;
#define DISP_LINE_LEN 16
int linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
ret = dm_i2c_read(dev, addr, linebuf, linebytes);
On systems where integers are 32 bits wide, 0x80000100 is a negative
value to "nbytes > DISP_LINE_LEN" is false and linebytes gets assigned
0x80000100 instead of 16.
The consequence is that the function which reads from the i2c device
(dm_i2c_read or i2c_read) is called with a 16-byte stack buffer to fill
but with a size parameter which is too large. In some cases, this could
trigger a crash. But with some i2c drivers, such as drivers/i2c/nx_i2c.c
(used with "nexell,s5pxx18-i2c" bus), the size is actually truncated to
a 16-bit integer. This is because function i2c_transfer expects an
unsigned short length. In such a case, an attacker who can control the
response of an i2c device can overwrite the return address of a function
and execute arbitrary code through Return-Oriented Programming.
Fix this issue by using unsigned integers types in do_i2c_md. While at
it, make also alen unsigned, as signed sizes can cause vulnerabilities
when people forgot to check that they can be negative.
Signed-off-by: Nicolas Iooss <nicolas.iooss+uboot@ledger.fr>
Reviewed-by: Heiko Schocher <hs@denx.de>
2022-06-28 15:51:56 -04:00
..
2022-03-02 13:59:29 -05:00
2021-08-02 13:32:14 -04:00
2022-05-16 11:31:33 +02:00
2022-05-26 18:37:55 +08:00
2020-12-13 07:58:17 -07:00
2021-08-02 13:32:14 -04:00
2021-08-02 21:35:50 -04:00
2017-02-08 15:56:28 -05:00
2021-02-26 15:30:55 +01:00
2021-08-02 13:32:14 -04:00
2022-04-29 11:11:36 -04:00
2022-05-05 15:06:02 -04:00
2021-03-05 10:25:43 +05:30
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2022-02-05 15:49:00 +01:00
2022-03-28 20:17:07 +02:00
2021-10-12 14:19:52 +02:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-04 15:58:31 -04:00
2021-08-02 13:32:14 -04:00
2021-03-27 15:04:30 +13:00
2022-03-28 20:17:07 +02:00
2021-08-26 08:08:11 +02:00
2020-05-18 18:36:55 -04:00
2022-04-25 10:00:04 -04:00
2022-05-28 10:59:27 +02:00
2022-04-25 10:00:04 -04:00
2021-08-02 13:32:14 -04:00
2022-03-31 14:12:23 -04:00
2022-05-31 07:57:02 +02:00
2022-04-25 10:00:04 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2020-12-13 16:51:08 -07:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2022-02-25 01:41:04 -05:00
2021-08-02 13:32:14 -04:00
2022-03-28 20:14:24 +02:00
2020-05-18 18:36:55 -04:00
2021-01-13 02:38:01 +01:00
2020-05-18 18:36:55 -04:00
2020-12-18 20:32:21 -07:00
2022-01-19 18:11:34 +01:00
2022-01-19 18:11:34 +01:00
2020-05-18 18:36:55 -04:00
2021-08-30 14:10:07 -04:00
2021-08-02 13:32:14 -04:00
2022-02-11 11:29:23 -05:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2020-07-07 15:37:13 -04:00
2021-01-25 01:15:33 +01:00
2022-03-23 07:27:37 +01:00
2022-01-15 10:57:22 +01:00
2022-04-09 21:06:31 +02:00
2021-11-16 14:35:09 -05:00
2022-03-15 16:19:29 -04:00
2020-05-18 18:36:55 -04:00
2022-03-10 08:28:36 -05:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2020-05-18 18:36:55 -04:00
2021-05-13 13:09:05 -04:00
2021-08-02 13:32:14 -04:00
2020-10-23 13:33:07 -04:00
2022-05-05 15:06:02 -04:00
2022-01-21 14:01:35 -05:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2020-07-07 15:36:59 -04:00
2022-02-18 18:12:23 +01:00
2020-05-18 18:36:55 -04:00
2022-04-20 11:14:39 -04:00
2022-05-06 14:39:15 -04:00
2020-05-18 18:36:55 -04:00
2020-05-18 18:36:55 -04:00
2021-12-05 09:23:15 -07:00
2022-06-28 15:51:56 -04:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2022-01-19 18:11:34 +01:00
2021-12-24 10:54:56 +08:00
2022-05-28 10:59:27 +02:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2019-12-04 17:10:51 -05:00
2019-12-04 17:10:51 -05:00
2020-05-18 18:36:55 -04:00
2021-10-25 14:29:37 -04:00
2021-08-02 13:32:14 -04:00
2020-12-13 16:51:08 -07:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2022-04-25 10:00:04 -04:00
2021-11-28 16:51:51 -07:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2022-05-05 15:06:02 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2022-01-19 18:11:34 +01:00
2020-10-28 11:49:31 -04:00
2021-10-26 15:26:45 -04:00
2022-01-21 14:01:35 -05:00
2022-06-19 15:53:09 +02:00
2022-04-07 16:50:42 -04:00
2020-05-18 18:36:55 -04:00
2022-05-05 15:06:02 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2020-07-08 17:21:46 -04:00
2022-01-15 10:57:22 +01:00
2021-08-02 13:32:14 -04:00
2022-01-28 17:58:41 -05:00
2022-01-19 18:11:34 +01:00
2020-05-18 18:36:55 -04:00
2020-12-18 20:32:21 -07:00
2021-07-27 14:50:47 -04:00
2021-07-27 14:50:47 -04:00
2022-02-14 13:03:49 -05:00
2021-09-30 08:08:56 -04:00
2022-03-04 15:20:06 -05:00
2021-11-11 19:02:43 -05:00
2021-08-31 17:46:37 -04:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2020-12-13 16:51:09 -07:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-02-02 15:33:42 -05:00
2021-09-30 08:08:56 -04:00
2020-05-18 18:36:55 -04:00
2022-01-19 18:11:34 +01:00
2022-05-23 09:33:10 -04:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2021-09-30 08:08:56 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2022-05-23 09:33:10 -04:00
2021-09-24 14:30:46 -04:00
2020-08-07 22:31:32 -04:00
2022-02-11 10:52:37 -05:00
2021-08-02 13:32:14 -04:00
2021-11-11 19:02:39 -05:00
2021-04-12 17:44:55 -04:00
2020-05-18 21:19:18 -04:00
2021-01-31 14:08:56 +01:00
2020-05-18 18:36:55 -04:00
2020-10-23 13:33:07 -04:00
2021-10-21 07:39:05 +02:00
2021-03-02 15:53:37 -05:00
2022-01-19 18:11:34 +01:00
2020-05-18 18:36:55 -04:00
2021-11-17 13:47:27 +02:00
2021-11-30 09:23:49 +01:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2022-04-14 15:39:15 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-10-09 13:09:56 -04:00
2021-12-26 23:02:19 +01:00
2020-05-18 18:36:55 -04:00
2021-10-30 22:55:00 +02:00
2021-08-02 13:32:14 -04:00
2021-09-17 12:10:44 -04:00
2022-04-09 21:06:31 +02:00
2021-08-02 13:32:14 -04:00
2020-05-18 18:36:55 -04:00
2020-05-18 18:36:55 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00
2021-08-02 13:32:14 -04:00