linux/arch
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
..
alpha This is the 5.10.58 stable release 2021-08-12 14:58:34 +02:00
arc ARC: Fix CONFIG_STACKDEPOT 2021-09-03 10:09:21 +02:00
arm This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
arm64 ANDROID: fips140: preserve RELA sections without relying on the module loader 2021-10-29 13:32:14 -07:00
c6x
csky This is the 5.10.50 stable release 2021-07-14 17:35:23 +02:00
h8300
hexagon hexagon: use common DISCARDS macro 2021-07-20 16:05:53 +02:00
ia64 This is the 5.10.53 stable release 2021-07-25 15:37:14 +02:00
m68k This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
microblaze
mips This is the 5.10.58 stable release 2021-08-12 14:58:34 +02:00
nds32 nds32: fix up stack guard gap 2021-07-28 14:35:46 +02:00
nios2
openrisc sched/core: Initialize the idle task with preemption disabled 2021-07-14 16:55:50 +02:00
parisc This is the 5.10.62 stable release 2021-09-03 10:51:56 +02:00
powerpc UPSTREAM: ubsan: enable for all*config builds 2021-10-21 08:33:13 -07:00
riscv This is the 5.10.62 stable release 2021-09-03 10:51:56 +02:00
s390 This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
sh This is the 5.10.50 stable release 2021-07-14 17:35:23 +02:00
sparc This is the 5.10.56 stable release 2021-08-04 15:02:23 +02:00
um This is the 5.10.52 stable release 2021-07-20 16:36:53 +02:00
x86 ANDROID: gki_defconfig: enable CONFIG_USB_CONFIGFS_F_UVC 2021-10-27 12:55:32 +00:00
xtensa This is the 5.10.63 stable release 2021-09-08 09:08:09 +02:00
.gitignore
Kconfig