security-advisory-tfv-3.rst 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. Advisory TFV-3 (CVE-2017-7563)
  2. ==============================
  3. +----------------+-------------------------------------------------------------+
  4. | Title | RO memory is always executable at AArch64 Secure EL1 |
  5. +================+=============================================================+
  6. | CVE ID | `CVE-2017-7563`_ |
  7. +----------------+-------------------------------------------------------------+
  8. | Date | 06 Apr 2017 |
  9. +----------------+-------------------------------------------------------------+
  10. | Versions | v1.3 (since `Pull Request #662`_) |
  11. | Affected | |
  12. +----------------+-------------------------------------------------------------+
  13. | Configurations | AArch64 BL2, TSP or other users of xlat_tables library |
  14. | Affected | executing at AArch64 Secure EL1 |
  15. +----------------+-------------------------------------------------------------+
  16. | Impact | Unexpected Privilege Escalation |
  17. +----------------+-------------------------------------------------------------+
  18. | Fix Version | `Pull Request #924`_ |
  19. +----------------+-------------------------------------------------------------+
  20. | Credit | ARM |
  21. +----------------+-------------------------------------------------------------+
  22. The translation table library in ARM Trusted Firmware (TF) (under
  23. ``lib/xlat_tables`` and ``lib/xlat_tables_v2``) provides APIs to help program
  24. translation tables in the MMU. The xlat\_tables client specifies its required
  25. memory mappings in the form of ``mmap_region`` structures. Each ``mmap_region``
  26. has memory attributes represented by the ``mmap_attr_t`` enumeration type. This
  27. contains flags to control data access permissions (``MT_RO``/``MT_RW``) and
  28. instruction execution permissions (``MT_EXECUTE``/``MT_EXECUTE_NEVER``). Thus a
  29. mapping specifying both ``MT_RO`` and ``MT_EXECUTE_NEVER`` should result in a
  30. Read-Only (RO), non-executable memory region.
  31. This feature does not work correctly for AArch64 images executing at Secure EL1.
  32. Any memory region mapped as RO will always be executable, regardless of whether
  33. the client specified ``MT_EXECUTE`` or ``MT_EXECUTE_NEVER``.
  34. The vulnerability is known to affect the BL2 and Test Secure Payload (TSP)
  35. images on platforms that enable the ``SEPARATE_CODE_AND_RODATA`` build option,
  36. which includes all ARM standard platforms, and the upstream Xilinx and NVidia
  37. platforms. The RO data section for these images on these platforms is
  38. unexpectedly executable instead of non-executable. Other platforms or
  39. ``xlat_tables`` clients may also be affected.
  40. The vulnerability primarily manifests itself after `Pull Request #662`_. Before
  41. that, ``xlat_tables`` clients could not specify instruction execution
  42. permissions separately to data access permissions. All RO normal memory regions
  43. were implicitly executable. Before `Pull Request #662`_. the vulnerability
  44. would only manifest itself for device memory mapped as RO; use of this mapping
  45. is considered rare, although the upstream QEMU platform uses this mapping when
  46. the ``DEVICE2_BASE`` build option is used.
  47. Note that one or more separate vulnerabilities are also required to exploit this
  48. vulnerability.
  49. The vulnerability is due to incorrect handling of the execute-never bits in the
  50. translation tables. The EL3 translation regime uses a single ``XN`` bit to
  51. determine whether a region is executable. The Secure EL1&0 translation regime
  52. handles 2 Virtual Address (VA) ranges and so uses 2 bits, ``UXN`` and ``PXN``.
  53. The ``xlat_tables`` library only handles the ``XN`` bit, which maps to ``UXN``
  54. in the Secure EL1&0 regime. As a result, this programs the Secure EL0 execution
  55. permissions but always leaves the memory as executable at Secure EL1.
  56. The vulnerability is mitigated by the following factors:
  57. - The xlat\_tables library ensures that all Read-Write (RW) memory regions are
  58. non-executable by setting the ``SCTLR_ELx.WXN`` bit. This overrides any value
  59. of the ``XN``, ``UXN`` or ``PXN`` bits in the translation tables. See the
  60. ``enable_mmu()`` function:
  61. ::
  62. sctlr = read_sctlr_el##_el(); \
  63. sctlr |= SCTLR_WXN_BIT | SCTLR_M_BIT; \
  64. - AArch32 configurations are unaffected. Here the ``XN`` bit controls execution
  65. privileges of the currently executing translation regime, which is the desired
  66. behaviour.
  67. - ARM TF EL3 code (for example BL1 and BL31) ensures that all non-secure memory
  68. mapped into the secure world is non-executable by setting the ``SCR_EL3.SIF``
  69. bit. See the ``el3_arch_init_common`` macro in ``el3_common_macros.S``.
  70. .. _CVE-2017-7563: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-7563
  71. .. _Pull Request #662: https://github.com/ARM-software/arm-trusted-firmware/pull/662
  72. .. _Pull Request #924: https://github.com/ARM-software/arm-trusted-firmware/pull/924