From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: "gechao@greatwall.com.cn" <gechao@greatwall.com.cn>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Ni, Ray" <ray.ni@intel.com>
Subject: Re: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type
Date: Wed, 13 Jan 2021 06:58:22 +0000 [thread overview]
Message-ID: <MWHPR11MB1647C006E4E60D0EA99FB5D9F6A90@MWHPR11MB1647.namprd11.prod.outlook.com> (raw)
In-Reply-To: <5d397bc53140165ed278ea5bf020b0c69acd18eb.1608632264.git.gechao@greatwall.com.cn>
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@greatwall.com.cn <gechao@greatwall.com.cn>
> Sent: Tuesday, December 22, 2020 6:19 PM
> To: devel@edk2.groups.io; Gao, Zhichao <zhichao.gao@intel.com>
> Cc: Ni, Ray <ray.ni@intel.com>; gechao <gechao@greatwall.com.cn>
> Subject: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer
> overflow with UINT8 type
>
> From: gechao <gechao@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@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
next prev parent reply other threads:[~2021-01-13 6:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-22 10:18 [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type gechao
2021-01-13 6:58 ` Gao, Zhichao [this message]
2021-01-13 9:12 ` 回复: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo bufferoverflow " gechao
2021-01-14 2:01 ` Gao, Zhichao
2021-01-14 2:13 ` 回复: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifobufferoverflow " gechao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MWHPR11MB1647C006E4E60D0EA99FB5D9F6A90@MWHPR11MB1647.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox