arm-trusted-firmware/plat
Sandrine Bailleux 85bebe18da refactor(console): disable getc() by default
The ability to read a character from the console constitutes an attack
vector into TF-A, as it gives attackers a means to inject arbitrary
data into TF-A. It is dangerous to keep that feature enabled if not
strictly necessary, especially in production firmware builds.

Thus, we need a way to disable this feature. Moreover, when it is
disabled, all related code should be eliminated from the firmware
binaries, such that no remnant/dead getc() code remains in memory,
which could otherwise be used as a gadget as part of a bigger security
attack.

This patch disables getc() feature by default. For legitimate getc()
use cases [1], it can be explicitly enabled by building TF-A with
ENABLE_CONSOLE_GETC=1.

The following changes are introduced when getc() is disabled:

- The multi-console framework no longer provides the console_getc()
  function.

- If the console driver selected by the platform attempts to register
  a getc() callback into the multi-console framework then TF-A will
  now fail to build.

  If registered through the assembly function finish_console_register():
  - On AArch64, you'll get:
      Error: undefined symbol CONSOLE_T_GETC used as an immediate value.
  - On AArch32, you'll get:
      Error: internal_relocation (type: OFFSET_IMM) not fixed up

  If registered through the C function console_register(), this requires
  populating a struct console with a getc field, which will trigger:
    error: 'console_t' {aka 'struct console'} has no member named 'getc'

- All console drivers which previously registered a getc() callback
  have been modified to do so only when ENABLE_CONSOLE_GETC=1.

[1] Example of such use cases would be:
    - Firmware recovery: retrieving a golden BL2 image over the console in
      order to repair a broken firmware on a bricked board.
    - Factory CLI tool: Drive some soak tests through the console.

Discussed on TF-A mailing list here:
https://lists.trustedfirmware.org/archives/list/tf-a@lists.trustedfirmware.org/thread/YS7F6RCNTWBTEOBLAXIRTXWIOYINVRW7/

Change-Id: Icb412304cd23dbdd7662df7cf8992267b7975cc5
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Acked-by: Baruch Siach <baruch@tkos.co.il>
2023-10-11 08:40:14 +02:00
..
allwinner feat(allwinner): use reset through scpi for warm/soft reset 2023-07-31 21:55:30 +02:00
amlogic Plat AXG: Fix PLAT_MAX_PWR_LVL value 2020-12-29 13:52:11 +00:00
arm Merge "feat(rmmd): enable SME for RMM" into integration 2023-10-03 14:29:17 +02:00
aspeed/ast2700 refactor(ast2700): adopt RESET_TO_BL31 boot flow 2023-09-28 10:23:06 +08:00
brcm chore(brcm): include cpu_helpers.S for bl2 build 2023-07-27 09:35:12 +01:00
common refactor(el3-runtime): plat_ic_has_interrupt_type returns bool 2023-09-25 17:09:15 -05:00
hisilicon fix(spmd): fix build error with spmd 2023-05-10 15:57:29 -05:00
imx refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
intel/soc chore: remove MULTI_CONSOLE_API references 2023-09-12 15:28:36 +02:00
marvell fix(tree): correct some typos 2023-05-09 15:57:12 +01:00
mediatek feat(mt8188): add DSB before udelay 2023-10-03 13:27:18 +08:00
nuvoton chore(npcm845x): remove pauth_helpers.S additions in platform makefile 2023-08-28 10:27:20 -05:00
nvidia/tegra refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
nxp fix(tree): correct some typos 2023-05-09 15:57:12 +01:00
qemu feat(qemu): implement firmware handoff on qemu 2023-09-27 11:45:00 -07:00
qti chore: remove MULTI_CONSOLE_API references 2023-09-12 15:28:36 +02:00
renesas chore: remove MULTI_CONSOLE_API references 2023-09-12 15:28:36 +02:00
rockchip chore: remove MULTI_CONSOLE_API references 2023-09-12 15:28:36 +02:00
rpi fix(el3-runtime): leverage generic interrupt controller helpers 2023-09-25 17:09:15 -05:00
socionext refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
st fix(st): enable RTC clock before accessing nv counter 2023-09-27 18:41:46 +02:00
ti/k3 fix(ti): fix TISCI API changes during refactor 2023-08-24 15:04:15 +05:30
xilinx refactor(zynqmp): use common code for prepare_dtb 2023-10-09 10:41:28 +05:30