arm-trusted-firmware/drivers
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 refactor(allwinner): use fdt_node_is_enabled() in AXP driver 2023-02-03 13:31:28 +00:00
amlogic refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
arm refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
auth feat(mbedtls-psa): use PSA crypto API during signature verification 2023-10-05 09:35:09 +01:00
brcm fix(tree): correct some typos 2023-05-09 15:57:12 +01:00
cadence refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
cfi/v2m coverity: fix MISRA violations 2020-02-18 10:47:46 -06:00
clk feat(clk): add a minimal clock framework 2021-12-22 13:07:23 +01:00
console refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
coreboot/cbmem_console/aarch64 Don't return error information from console_flush 2020-10-09 10:21:50 -05:00
delay_timer include: move MHZ_TICKS_PER_SEC to utils_def.h 2020-02-20 09:25:45 -08:00
fwu fix(fwu): rename is_fwu_initialized 2022-03-28 09:10:11 +02:00
gpio Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
imx fix: unify fallthrough annotations 2022-12-01 16:17:24 +00:00
intel/soc/stratix10/io io: change seek offset to signed long long 2020-01-10 21:14:57 +01:00
io chore(io): remove io_dummy driver 2023-04-28 15:45:43 +02:00
marvell refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
measured_boot feat(rss): set the signer-ID in the RSS metadata 2023-07-28 09:01:15 +01:00
mentor/i2c Enable -Wlogical-op always 2019-11-19 08:53:21 -06:00
mmc fix(mmc): initialises response buffer with zeros 2023-09-16 10:42:39 +00:00
mtd fix(nand): reset the SLC NAND 2023-09-27 16:21:58 +02:00
nxp refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
partition fix(partition): add missing curly braces 2022-12-07 14:16:48 +01:00
rambus drivers/rambus: add TRNG-IP-76 driver 2021-02-11 09:43:18 +00:00
renesas fix(tree): correct some typos 2023-05-09 15:57:12 +01:00
rpi3 fix(rpi3): initialize SD card host controller 2023-04-13 10:29:51 +01:00
scmi-msg fix(scmi): add parameter for plat_scmi_clock_rates_array 2023-08-21 19:46:52 +08:00
st fix(st-crypto): use GENMASK_32 to define PKA registers masks 2023-09-27 18:41:46 +02:00
synopsys Merge changes from topic "jc/shift-overflow" into integration 2019-07-16 10:11:27 +00:00
ti/uart refactor(console): disable getc() by default 2023-10-11 08:40:14 +02:00
ufs fix(ufs): performs unsigned shift for doorbell 2023-09-16 10:53:09 +00:00
usb fix(usb): correct type in message 2022-02-15 18:09:51 +01:00