]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.33/kbuild-modversions-fix-relative-crc-byte-order-interpretation.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.19.33 / kbuild-modversions-fix-relative-crc-byte-order-interpretation.patch
1 From 54a7151b1496cddbb7a83546b7998103e98edc88 Mon Sep 17 00:00:00 2001
2 From: Fredrik Noring <noring@nocrew.org>
3 Date: Wed, 27 Mar 2019 19:12:50 +0100
4 Subject: kbuild: modversions: Fix relative CRC byte order interpretation
5
6 From: Fredrik Noring <noring@nocrew.org>
7
8 commit 54a7151b1496cddbb7a83546b7998103e98edc88 upstream.
9
10 Fix commit 56067812d5b0 ("kbuild: modversions: add infrastructure for
11 emitting relative CRCs") where CRCs are interpreted in host byte order
12 rather than proper kernel byte order. The bug is conditional on
13 CONFIG_MODULE_REL_CRCS.
14
15 For example, when loading a BE module into a BE kernel compiled with a LE
16 system, the error "disagrees about version of symbol module_layout" is
17 produced. A message such as "Found checksum D7FA6856 vs module 5668FAD7"
18 will be given with debug enabled, which indicates an obvious endian
19 problem within __kcrctab within the kernel image.
20
21 The general solution is to use the macro TO_NATIVE, as is done in
22 similar cases throughout modpost.c. With this correction it has been
23 verified that a BE kernel compiled with a LE system accepts BE modules.
24
25 This change has also been verified with a LE kernel compiled with a LE
26 system, in which case TO_NATIVE returns its value unmodified since the
27 byte orders match. This is by far the common case.
28
29 Fixes: 56067812d5b0 ("kbuild: modversions: add infrastructure for emitting relative CRCs")
30 Signed-off-by: Fredrik Noring <noring@nocrew.org>
31 Cc: stable@vger.kernel.org
32 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35 ---
36 scripts/mod/modpost.c | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
38
39 --- a/scripts/mod/modpost.c
40 +++ b/scripts/mod/modpost.c
41 @@ -640,7 +640,7 @@ static void handle_modversions(struct mo
42 info->sechdrs[sym->st_shndx].sh_offset -
43 (info->hdr->e_type != ET_REL ?
44 info->sechdrs[sym->st_shndx].sh_addr : 0);
45 - crc = *crcp;
46 + crc = TO_NATIVE(*crcp);
47 }
48 sym_update_crc(symname + strlen("__crc_"), mod, crc,
49 export);