Masahiro Yamada
7aa910df07
modpost: fix undefined behavior of is_arm_mapping_symbol()
...
[ Upstream commit d6b732666a ]
The return value of is_arm_mapping_symbol() is unpredictable when "$"
is passed in.
strchr(3) says:
The strchr() and strrchr() functions return a pointer to the matched
character or NULL if the character is not found. The terminating null
byte is considered part of the string, so that if c is specified as
'\0', these functions return a pointer to the terminator.
When str[1] is '\0', strchr("axtd", str[1]) is not NULL, and str[2] is
referenced (i.e. buffer overrun).
Test code
---------
char str1[] = "abc";
char str2[] = "ab";
strcpy(str1, "$");
strcpy(str2, "$");
printf("test1: %d\n", is_arm_mapping_symbol(str1));
printf("test2: %d\n", is_arm_mapping_symbol(str2));
Result
------
test1: 0
test2: 1
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org >
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2022-06-14 16:52:40 +02:00
..
2016-08-24 22:34:19 +02:00
2019-06-11 12:22:49 +02:00
2022-01-27 08:47:42 +01:00
2022-04-20 09:06:46 +02:00
2021-01-12 19:49:03 +01:00
2016-08-25 20:03:51 +02:00
2021-05-22 10:40:30 +02:00
2022-06-14 16:52:40 +02:00
2018-05-30 07:50:39 +02:00
2015-07-13 13:32:00 -04:00
2021-08-15 13:01:03 +02:00
2016-02-26 15:30:20 +00:00
2018-05-30 07:50:37 +02:00
2021-06-03 08:23:27 +02:00
2016-04-06 14:06:48 +01:00
2021-06-03 08:23:27 +02:00
2021-06-03 08:23:27 +02:00
2015-04-13 21:03:02 +09:30
2015-09-28 01:31:48 -06:00
2021-06-03 08:23:27 +02:00
2016-08-28 11:08:34 +02:00
2020-12-29 13:45:01 +01:00
2021-06-03 08:23:27 +02:00
2015-06-04 07:37:37 +02:00
2017-12-14 09:28:22 +01:00
2021-06-03 08:23:27 +02:00
2014-04-30 17:34:32 +02:00
2016-10-11 15:06:30 -07:00
2020-07-31 16:44:03 +02:00
2020-05-20 08:15:29 +02:00
2021-01-12 19:49:01 +01:00
2021-06-03 08:23:27 +02:00
2016-05-14 09:56:56 -06:00
2014-08-20 16:03:45 +02:00
2021-06-03 08:23:27 +02:00
2015-09-25 16:31:45 +01:00
2015-04-15 14:01:12 +02:00
2015-10-21 15:18:36 +01:00
2016-02-26 15:32:05 +00:00
2016-09-19 14:49:08 -07:00
2014-08-20 16:03:45 +02:00
2014-08-20 16:03:45 +02:00
2016-08-08 17:49:05 -07:00
2014-08-20 16:03:45 +02:00
2014-08-20 16:03:45 +02:00
2016-11-09 22:28:05 +01:00
2016-09-23 10:35:32 +02:00
2021-06-03 08:23:27 +02:00
2016-08-26 17:39:34 -07:00
2016-05-24 14:12:48 +10:00
2014-10-14 09:22:26 +02:00
2014-12-20 00:01:12 +01:00
2016-02-26 15:30:20 +00:00
2020-01-04 13:41:02 +01:00
2020-06-30 15:38:43 -04:00
2018-02-25 11:05:47 +01:00
2015-08-16 22:11:16 -06:00
2016-05-13 14:02:05 +02:00
2015-09-04 16:54:41 -07:00
2016-09-09 10:31:19 +02:00
2021-03-07 11:25:55 +01:00
2016-07-07 15:58:45 +02:00
2021-02-23 13:59:17 +01:00
2016-06-07 22:57:10 +02:00
2016-01-28 11:40:32 +01:00
2022-02-23 11:56:38 +01:00
2015-04-02 16:42:08 +02:00
2016-10-10 14:51:44 -07:00
2014-11-26 14:36:52 +01:00
2018-11-23 08:20:35 +01:00
2018-08-17 20:59:29 +02:00
2018-11-23 08:20:35 +01:00
2015-08-07 16:26:13 +01:00
2019-08-25 10:51:47 +02:00
2014-08-27 21:54:11 +09:30
2016-11-11 08:45:08 -08:00
2021-06-03 08:23:27 +02:00
2021-07-28 09:14:25 +02:00
2014-08-20 16:03:45 +02:00
2020-06-30 15:38:23 -04:00
2018-01-17 09:38:58 +01:00
2019-10-29 09:15:06 +01:00
2014-06-10 14:59:33 +02:00
2014-04-30 17:34:32 +02:00
2014-06-10 00:04:06 +02:00
2021-06-03 08:23:27 +02:00
2016-02-09 10:09:52 -08:00
2021-03-17 16:10:15 +01:00
2019-08-04 09:33:38 +02:00
2022-01-05 12:31:24 +01:00
2020-11-10 10:23:50 +01:00
2021-06-03 08:23:27 +02:00
2016-06-14 13:18:33 +01:00
2016-03-23 16:00:46 +01:00
2014-10-14 02:18:23 +02:00
2016-10-07 18:46:30 -07:00
2021-06-03 08:23:27 +02:00
2015-08-28 17:04:40 +02:00
2018-04-13 19:48:21 +02:00
2018-12-08 13:05:05 +01:00
2016-08-31 13:59:31 +02:00
2015-03-16 14:49:13 +00:00
2014-08-20 16:03:45 +02:00