[edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type

Gao, Zhichao zhichao.gao at intel.com
Wed Jan 13 06:58:22 UTC 2021


Hi,

Sorry, I don't understand the patch. UINT8 type would have the value limitation. But why does it affect the buffer size?
Did you observed the overflow with the original value? If yes, can you share the example?

Thanks,
Zhichao

> -----Original Message-----
> From: gechao at greatwall.com.cn <gechao at greatwall.com.cn>
> Sent: Tuesday, December 22, 2020 6:19 PM
> To: devel at edk2.groups.io; Gao, Zhichao <zhichao.gao at intel.com>
> Cc: Ni, Ray <ray.ni at intel.com>; gechao <gechao at greatwall.com.cn>
> Subject: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer
> overflow with UINT8 type
> 
> From: gechao <gechao at greatwall.com.cn>
> 
> The maximum fifo buffer length is RAW_FIFO_MAX_NUMBER + 1 = 257, but
> the maximum value of terminal fifo buffer index is sizeof(UINT8) - 1 = 255 with
> UINT8 type, so check if fifo buffer is empty or full with below expression, ((Tail
> + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head, (Tail + 1) might be
> sizeof(UINT8) + 1 = 256, for UINT8 type, it does not make any sense.
> 
> Signed-off-by: gechao <gechao at greatwall.com.cn>
> ---
>  MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> index 378ace13ce..360e58e847 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> @@ -37,7 +37,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #include <Library/BaseLib.h>  -#define RAW_FIFO_MAX_NUMBER
> 256+#define RAW_FIFO_MAX_NUMBER 255 #define FIFO_MAX_NUMBER
> 128  typedef struct {--
> 2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70206): https://edk2.groups.io/g/devel/message/70206
Mute This Topic: https://groups.io/mt/79282845/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list