1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-22 07:53:11 -05:00
linux/scripts/mod
Masahiro Yamada 8fe1a63d3d modpost: work around unaligned data access error
With the latest binutils, modpost fails with a bus error on some
architectures such as ARM and sparc64.

Since binutils commit 1f1b5e506bf0 ("bfd/ELF: restrict file alignment
for object files"), the byte offset to each section (sh_offset) in
relocatable ELF is no longer guaranteed to be aligned.

modpost parses MODULE_DEVICE_TABLE() data structures, which are usually
located in the .rodata section. If it is not properly aligned, unaligned
access errors may occur.

To address the issue, this commit imports the get_unaligned() helper
from include/linux/unaligned.h.

The get_unaligned_native() helper caters to the endianness in addition
to handling the unaligned access.

I slightly refactored do_pcmcia_entry() and do_input() to avoid writing
back to an unaligned address. (We would need the put_unaligned() helper
to do that.)

The addend_*_rel() functions need similar adjustments because the .text
sections are not aligned either.

It seems that the .symtab, .rel.* and .rela.* sections are still aligned.
Keep normal pointer access for these sections to avoid unnecessary
performance costs.

Reported-by: Paulo Pisati <paolo.pisati@canonical.com>
Reported-by: Matthias Klose <doko@debian.org>
Closes: https://sourceware.org/bugzilla/show_bug.cgi?id=32435
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Closes: https://sourceware.org/bugzilla/show_bug.cgi?id=32493
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2024-12-28 23:31:09 +09:00
..
.gitignore
devicetable-offsets.c slimbus: generate MODULE_ALIAS() from MODULE_DEVICE_TABLE() 2024-09-03 12:10:39 +02:00
empty.c
file2alias.c modpost: work around unaligned data access error 2024-12-28 23:31:09 +09:00
Makefile Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
mk_elfconfig.c modpost: detect endianness on run-time 2024-09-01 20:33:32 +09:00
modpost.c modpost: work around unaligned data access error 2024-12-28 23:31:09 +09:00
modpost.h modpost: work around unaligned data access error 2024-12-28 23:31:09 +09:00
sumversion.c sumversion: Fix a memory leak in get_src_version() 2024-10-23 16:11:13 +09:00
symsearch.c modpost: replace the use of NOFAIL() with xmalloc() etc. 2024-09-01 20:34:48 +09:00