linux/scripts/mod
Masahiro Yamada 4adc7d7ee6 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 18:36:23 +02:00
..
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
devicetable-offsets.c PCI / VFIO: Add 'override_only' support for VFIO PCI sub system 2021-08-26 10:36:51 -06:00
empty.c
file2alias.c PCI / VFIO: Add 'override_only' support for VFIO PCI sub system 2021-08-26 10:36:51 -06:00
Makefile scripts/mod: disable LTO for empty.c 2021-01-14 08:21:09 -08:00
mk_elfconfig.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
modpost.c modpost: fix undefined behavior of is_arm_mapping_symbol() 2022-06-14 18:36:23 +02:00
modpost.h modpost: get the *.mod file path more simply 2021-09-03 08:17:21 +09:00
sumversion.c modpost: get the *.mod file path more simply 2021-09-03 08:17:21 +09:00