> For the complete documentation index, see [llms.txt](https://edk2-docs.gitbook.io/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edk2-docs.gitbook.io/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md).

# Future work

Both software and hardware-based advances can be added to strengthen code against this class of issue. On the software front, language-based security may offer some relief. This can span using a safer variant of C \[[CHECKED\_\_C](https://www.microsoft.com/en-us/research/project/checked-c/)] [\[1\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md#footnote1) to refactoring code to a type-safe language \[[RUST](https://github.com/www.rust-lang.org/en-US/README.md)][\[2\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md#footnote2). These are huge tasks, though, given the existing software catalog and would challenge software portability. As such, a language-based approach is not a near term option.

As we go from software to hardware, though, one option appears feasible. Specifically, recent hardware advances include the Intel® Memory Protection Extensions (Intel® MPX). This is a new capability introduced into Intel Architecture \[[IA32SDM](http://www.intel.com)][\[3\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md#footnote3)\[[MPX](https://software.intel.com/en-us/articles/intel-memory-protection-extensions-enabling-guide)][\[4\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md#footnote4). Intel MPX can help detect the buffer overflow or underflow with a set of new Intel® MPX instructions and the compiler support. When Intel® MPX is enabled, a Bounds Table is constructed to store the pointer value, lower bound of the buffer, and the upper bound of the buffer. See figure 4-12.

The `BNDMK`instruction can create LowerBound (`LB`) and UpperBound (`UB`) in bounds register. The `BNDCL/BNDCU/BNDCN` instruction can check the address of a memory reference or address against the `LB` or `UB`. A BOUND Range Exceeded exception (`#BR`) is raised if any of the bounds compare instructions fail.

Intel® MPX need compiler support. Microsoft MSVC 2015\* Update 1 and GCC 5.1\* supports Intel MPX.

![](https://1538240294-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5spcVnZfIHxfePpMzK%2F-M5sphYdfgyXfsRA7x6D%2F-M5spiMnILkSc2jCJo3a%2Fimage27.png?generation=1587944052678743\&alt=media)

### Figure 4-12 Bound Table, (source: \[[MPX](https://software.intel.com/en-us/articles/intel-memory-protection-extensions-enabling-guide)][\[4\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md#footnote4)

Intel® MPX may also be considered to add to a UEFI firmware to help catch the heap pool overflow or the global variable overflow.

## Summary <a href="#summary" id="summary"></a>

This section discussed some other mechanism which can be used to detect stack overflow or heap overflow in EDK II.

&#x20;[\[1\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md)\[[CHECKED\_\_C](https://www.microsoft.com/en-us/research/project/checked-c/)] Checked C [\[2\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md) \[[RUST](https://github.com/www.rust-lang.org/en-US/README.md)] Rust language [\[3\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md)\[[IA32SDM](http://www.intel.com)]Intel® 64 and IA-32 Architectures Software Developer’s Manual [\[4\]](/a-tour-beyond-bios-mitigate-buffer-overflow-in-ue/additional_overflow_detection/future_work.md)\[[MPX](https://software.intel.com/en-us/articles/intel-memory-protection-extensions-enabling-guide)] Intel® Memory Protection Extensions Enabling Guide
