Skip to content

Commit 54a7151

Browse files
frno7masahir0y
authored andcommitted
kbuild: modversions: Fix relative CRC byte order interpretation
Fix commit 5606781 ("kbuild: modversions: add infrastructure for emitting relative CRCs") where CRCs are interpreted in host byte order rather than proper kernel byte order. The bug is conditional on CONFIG_MODULE_REL_CRCS. For example, when loading a BE module into a BE kernel compiled with a LE system, the error "disagrees about version of symbol module_layout" is produced. A message such as "Found checksum D7FA6856 vs module 5668FAD7" will be given with debug enabled, which indicates an obvious endian problem within __kcrctab within the kernel image. The general solution is to use the macro TO_NATIVE, as is done in similar cases throughout modpost.c. With this correction it has been verified that a BE kernel compiled with a LE system accepts BE modules. This change has also been verified with a LE kernel compiled with a LE system, in which case TO_NATIVE returns its value unmodified since the byte orders match. This is by far the common case. Fixes: 5606781 ("kbuild: modversions: add infrastructure for emitting relative CRCs") Signed-off-by: Fredrik Noring <noring@nocrew.org> Cc: stable@vger.kernel.org Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 7fcddf7 commit 54a7151

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/mod/modpost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
639639
info->sechdrs[sym->st_shndx].sh_offset -
640640
(info->hdr->e_type != ET_REL ?
641641
info->sechdrs[sym->st_shndx].sh_addr : 0);
642-
crc = *crcp;
642+
crc = TO_NATIVE(*crcp);
643643
}
644644
sym_update_crc(symname + strlen("__crc_"), mod, crc,
645645
export);

0 commit comments

Comments
 (0)