modpost: Get proper section index by get_secindex() instead of st_shndx
authorXiao Yang <yangx.jy@cn.fujitsu.com>
Wed, 18 Mar 2020 10:34:16 +0000 (18:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2020 07:27:09 +0000 (08:27 +0100)
commitc325c96b4b15c00a74bd6aa3321e10c84a67ef35
tree9a76f83b5255ce887eee05ddfd897309cd44378a
parent492b7e9392a4ef25ef6dff3614f32a7099cf69d8
modpost: Get proper section index by get_secindex() instead of st_shndx

commit 4b8a5cfb5fd375cf4c7502a18f0096ed2881be27 upstream.

(uint16_t) st_shndx is limited to 65535(i.e. SHN_XINDEX) so sym_get_data() gets
wrong section index by st_shndx if requested symbol contains extended section
index that is more than 65535.  In this case, we need to get proper section index
by .symtab_shndx section.

Module.symvers generated by building kernel with "-ffunction-sections -fdata-sections"
shows the issue.

Fixes: 56067812d5b0 ("kbuild: modversions: add infrastructure for emitting relative CRCs")
Fixes: e84f9fbbece1 ("modpost: refactor namespace_from_kstrtabns() to not hard-code section name")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/mod/modpost.c