Commit e75c894d authored by Fredrik Noring's avatar Fredrik Noring Committed by Greg Kroah-Hartman
Browse files

kbuild: modversions: Fix relative CRC byte order interpretation

commit 54a7151b upstream.

Fix commit 56067812 ("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

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: 56067812

 ("kbuild: modversions: add infrastructure for emitting relative CRCs")
Signed-off-by: default avatarFredrik Noring <>
Signed-off-by: Masahiro Yamada's avatarMasahiro Yamada <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent fe2d6d04
......@@ -645,7 +645,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
info->sechdrs[sym->st_shndx].sh_offset -
(info->hdr->e_type != ET_REL ?
info->sechdrs[sym->st_shndx].sh_addr : 0);
crc = *crcp;
crc = TO_NATIVE(*crcp);
sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment