OrangePi_CM5/arch/arm64
Ard Biesheuvel 6b995f5a54 ANDROID: fips140: preserve RELA sections without relying on the module loader
Instead of having a special case in the core kernel's module loader that
treats a module called 'fips140.ko' in a special way, use a host tool to
tweak the ELF metadata of this module so that the RELA data is preserved
and accessible to the module init code.

This is done in the following way:
- each RELA section that we care about (the ones for .text and .rodata
  at the moment) is copied into a new section called .init.rela.<name>
  with the SHF_ALLOC attribute, so that the module loader will copy it
  into __init memory at load time;
- for each such section, an offset/count tuple is added as a global
  variable to the module;
- the count field of those tuples is populated directly by the host tool
  based on the actual size of the RELA section in question;
- the offset field is decorated with a place-relative relocation against
  the start of the copied RELA section via a weak symbol reference,
  which causes an entry to be emitted into the ELF symbol table;
- these ELF symbol table entries are updated by the host tool and turned
  into STT_SECTION type symbols with STB_GLOBAL linkage, carrying the
  correct section index.

With these changes in place, the unmodified module loader will load all
required information into memory in a way that permits the module init
code to locate the relocations, and apply them in reverse.

Bug: 153614920
Bug: 188620248
Change-Id: I07d9704febdf913834502dd09c19aa4a04d983b1
Signed-off-by: Ard Biesheuvel <ardb@google.com>
(cherry picked from commit 502af6e3490d3ed51cf2131306303445b0d56579)
2021-10-29 13:32:14 -07:00
..
boot This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
configs ANDROID: gki_defconfig: enable CONFIG_USB_CONFIGFS_F_UVC 2021-10-27 12:55:32 +00:00
crypto ANDROID: crypto: fips140 - perform load time integrity check 2021-06-11 07:49:58 +00:00
include Merge tag 'android12-5.10.66_r00' into android12-5.10 2021-10-21 09:45:02 +02:00
kernel Revert "ANDROID: mpam: add vendor hook to record MPAM" 2021-10-27 08:05:03 +02:00
kvm Merge branch 'android12-5.10' into `android12-5.10-lts` 2021-09-02 09:02:06 +02:00
lib BACKPORT: FROMGIT: arm64: mte: handle tags zeroing at page allocation time 2021-06-17 14:39:37 -07:00
mm Merge tag 'android12-5.10.66_r00' into android12-5.10 2021-10-21 09:45:02 +02:00
net This is the 5.10.56 stable release 2021-08-04 15:02:23 +02:00
xen
Kbuild
Kconfig UPSTREAM: arm64: Kconfig: select KASAN_VMALLOC if KANSAN_GENERIC is enabled 2021-10-04 15:44:41 +00:00
Kconfig.debug arm64: remove TEXT_OFFSET randomization 2020-06-15 13:10:59 +01:00
Kconfig.platforms FROMLIST: arm64: meson: remove MESON_IRQ_GPIO selection 2021-02-11 14:43:13 +00:00
Makefile ANDROID: Don't add image to all target with KBUILD_MIXED_TREE 2021-05-22 09:43:36 +00:00
Makefile.postlink ANDROID: fips140: preserve RELA sections without relying on the module loader 2021-10-29 13:32:14 -07:00