arm-trusted-firmware/plat/socionext/uniphier
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
..
include uniphier: define PLAT_XLAT_TABLES_DYNAMIC only for BL2 2020-04-02 15:16:31 +09:00
tsp uniphier: use enable_mmu() in common function 2020-04-01 16:40:16 +02:00
platform.mk refactor(build): distinguish BL2 as TF-A entry point and BL2 running at EL3 2023-03-15 11:43:14 +00:00
uniphier.h uniphier: make I/O register region configurable 2020-02-12 13:36:58 +09:00
uniphier_bl2_setup.c uniphier: increase BL33 max size and GZIP temporary buffer size 2020-06-29 16:57:11 +09:00
uniphier_bl31_setup.c uniphier: use enable_mmu() in common function 2020-04-01 16:40:16 +02:00
uniphier_boot_device.c uniphier: make pinmon base address configurable 2020-02-12 13:36:58 +09:00
uniphier_cci.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
uniphier_console.h uniphier: support console based on multi-console 2019-07-05 18:43:16 +09:00
uniphier_console.S Don't return error information from console_flush 2020-10-09 10:21:50 -05:00
uniphier_console_setup.c refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
uniphier_emmc.c uniphier: make eMMC controller base address configurable 2020-02-12 13:36:58 +09:00
uniphier_gicv3.c uniphier: fix typo and coding style 2019-07-31 16:35:29 +09:00
uniphier_helpers.S uniphier: support Socionext UniPhier platform 2017-06-13 00:32:57 +09:00
uniphier_image_desc.c uniphier: increase BL33 max size and GZIP temporary buffer size 2020-06-29 16:57:11 +09:00
uniphier_io_storage.c uniphier: increase BL33 max size and GZIP temporary buffer size 2020-06-29 16:57:11 +09:00
uniphier_nand.c uniphier: make NAND controller base address configurable 2020-02-12 13:36:58 +09:00
uniphier_psci.c uniphier: make PSCI related base address configurable 2020-02-12 13:36:58 +09:00
uniphier_rotpk.S uniphier: move ROTPK hash to .rodata section 2017-10-18 21:57:34 +09:00
uniphier_scp.c uniphier: pass SCP base address as a function parameter 2020-01-24 22:34:50 +09:00
uniphier_smp.S uniphier: support Socionext UniPhier platform 2017-06-13 00:32:57 +09:00
uniphier_soc_info.c uniphier: prepare uniphier_soc_info() for next SoC 2020-02-26 17:55:11 +09:00
uniphier_syscnt.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
uniphier_tbbr.c Mbed TLS: Remove weak heap implementation 2019-04-12 09:52:52 +01:00
uniphier_topology.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
uniphier_usb.c uniphier: set buffer offset and length for io_block dynamically 2020-01-24 22:34:50 +09:00
uniphier_xlat_setup.c uniphier: support read-only xlat tables 2020-04-01 16:40:16 +02:00