[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/8] log: Avoid buffer overrun in DbgPrint interception


  • To: Owen Smith <owen.smith@xxxxxxxxxx>, win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Fri, 14 Aug 2026 12:07:28 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Delivery-date: Fri, 14 Aug 2026 10:07:32 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 14/08/2026 09:30, Owen Smith wrote:
> Truncate incomming strings to fit inside a Slot's Buffer
> 
> Assisted-by: ClaudeCode:claude-opus-4.8
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>

> ---
>   src/xen/log.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/xen/log.c b/src/xen/log.c
> index 8673105..93039f6 100644
> --- a/src/xen/log.c
> +++ b/src/xen/log.c
> @@ -545,6 +545,7 @@ LogDebugPrint(
>   {
>       PLOG_CONTEXT        Context = &LogContext;
>       KIRQL               Irql;
> +    ULONG               Length;
>       PLOG_SLOT           Slot;
>   
>       UNREFERENCED_PARAMETER(ComponentId);
> @@ -571,9 +572,14 @@ LogDebugPrint(
>   
>       Slot = &Context->Slot[Context->Pending++];
>   
> +    // truncate long log lines - avoid buffer overrun on Slot->Buffer
> +    Length = Ansi->Length >= LOG_BUFFER_SIZE ?
> +                            LOG_BUFFER_SIZE - 1:
> +                            Ansi->Length;
> +
>       Slot->Level = 1 << Level;
> -    RtlCopyMemory(Slot->Buffer, Ansi->Buffer, Ansi->Length);
> -    Slot->Offset = Ansi->Length;
> +    RtlCopyMemory(Slot->Buffer, Ansi->Buffer, Length);
> +    Slot->Offset = Length;
>   
>       ReleaseHighLock(&Context->Lock, Irql);
>   



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.