All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: dmukhin@ford.com
Cc: xen-devel@lists.xenproject.org, andrew.cooper3@citrix.com,
	 anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org,
	 michal.orzel@amd.com, roger.pau@citrix.com,
	sstabellini@kernel.org
Subject: Re: [PATCH v8 6/7] xen/serial: harden serial_tx_buffer checks
Date: Mon, 10 Aug 2026 13:32:11 -0700 (PDT)	[thread overview]
Message-ID: <4b040e58-9020-a519-00cb-816ce2fddaa0@kernel.org> (raw)
In-Reply-To: <20260728065049.1318143-7-dmukhin@ford.com>

On Mon, 27 Jul 2026, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com> 
> 
> Ensure the user-defined value never crosses 2GB boundary and always
> rounded to the next power of 2 to align logic with console driver
> conring buffer management code.
> 
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> Changes since v7:
> - addressed Jan's feedback:
>   https://lore.kernel.org/xen-devel/89029dbd-df1f-45d4-8a02-720cd6a42cab@suse.com/
> - kept only check for large buffer in serial_async_transmit()
>   and a doc update.
> ---
>  docs/misc/xen-command-line.pandoc | 2 ++
>  xen/drivers/char/serial.c         | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
> index 1c711fa98086..2be8772b329a 100644
> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -2396,6 +2396,8 @@ accidentally leaking secrets by releasing pages without proper sanitization.
>  
>  Set the serial transmit buffer size.
>  
> +The value provided will be rounded down to the nearest power of 2.
> +
>  ### serrors (ARM)
>  > `= diverse | panic`
>  
> diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
> index cf0abf1893e5..ba1647309ab8 100644
> --- a/xen/drivers/char/serial.c
> +++ b/xen/drivers/char/serial.c
> @@ -523,6 +523,8 @@ void __init serial_async_transmit(struct serial_port *port)
>          return;
>      if ( serial_txbufsz < PAGE_SIZE )
>          serial_txbufsz = PAGE_SIZE;
> +    if ( serial_txbufsz > GB(2) )
> +        serial_txbufsz = CONFIG_SERIAL_TX_BUFSIZE;
>      while ( serial_txbufsz & (serial_txbufsz - 1) )
>          serial_txbufsz &= serial_txbufsz - 1;

My understanding of this loop is that, given that serial_txbufsz is
unsigned int, it is already clamping it to 2GB max


>      port->txbuf = xvmalloc_array(char, serial_txbufsz);
> -- 
> 2.54.0
> 


  reply	other threads:[~2026-08-10 20:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  6:50 [PATCH v8 0/7] xen/console: some cleanups and configurable conring size dmukhin
2026-07-28  6:50 ` [PATCH v8 1/7] xen/console: do not use XENCONS_RING_IDX in console_init_ring() dmukhin
2026-08-10 20:03   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 2/7] xen/console: use 'unsigned int' in contring_{flush,puts}() dmukhin
2026-08-10 20:05   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 3/7] xen/console: switch conring runtime allocation to xvmalloc dmukhin
2026-08-10 20:19   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 4/7] xen/serial: switch txbuf " dmukhin
2026-08-10 20:22   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 5/7] xen/console: use memcpy() in conring_puts() dmukhin
2026-08-10 20:24   ` Stefano Stabellini
2026-08-10 21:36   ` Stefano Stabellini
2026-08-10 21:37   ` Andrew Cooper
2026-07-28  6:50 ` [PATCH v8 6/7] xen/serial: harden serial_tx_buffer checks dmukhin
2026-08-10 20:32   ` Stefano Stabellini [this message]
2026-07-28  6:50 ` [PATCH v8 7/7] xen/console: make console buffer size configurable dmukhin
2026-08-10 20:42   ` Stefano Stabellini

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-all 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=4b040e58-9020-a519-00cb-816ce2fddaa0@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=dmukhin@ford.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.