public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Junrui Luo <moonafterrain@outlook.com>
Cc: Brad Warrum <bwarrum@linux.ibm.com>,
	Ritu Agarwal <rituagar@linux.ibm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Adam Reznechek <adreznec@linux.vnet.ibm.com>,
	Steven Royer <seroyer@linux.vnet.ibm.com>,
	"Bryant G. Ly" <bryantly@linux.vnet.ibm.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	linux-kernel@vger.kernel.org, Yuhao Jiang <danisjiang@gmail.com>
Subject: Re: [PATCH] misc: ibmvmc: fix buffer overflow in ibmvmc_recv_msg()
Date: Thu, 18 Dec 2025 15:57:49 +0100	[thread overview]
Message-ID: <2025121804-angles-driller-7c7c@gregkh> (raw)
In-Reply-To: <MEYPR01MB7886EBCF9C20CD275A572F65AFA8A@MEYPR01MB7886.ausprd01.prod.outlook.com>

On Thu, Dec 18, 2025 at 10:43:11PM +0800, Junrui Luo wrote:
> The ibmvmc_recv_msg() function receives a msg_len value from the
> hypervisor and uses it directly in h_copy_rdma() without validating.
> This can result a buffer overflow.
> 
> Add a check to ensure msg_len does not exceed buffer->size before
> calling h_copy_rdma().
> 
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Reported-by: Junrui Luo <moonafterrain@outlook.com>
> Fixes: 0eca353e7ae7 ("misc: IBM Virtual Management Channel Driver (VMC)")
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
> ---
>  drivers/misc/ibmvmc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
> index e5f935b5249d..e583a73a3592 100644
> --- a/drivers/misc/ibmvmc.c
> +++ b/drivers/misc/ibmvmc.c
> @@ -1654,6 +1654,12 @@ static int ibmvmc_recv_msg(struct crq_server_adapter *adapter,
>  	}
>  
>  	/* RDMA the data into the partition. */
> +	if (msg_len > buffer->size) {
> +		dev_err(adapter->dev, "Recv_msg: msg_len 0x%x exceeds buffer size 0x%x\n",
> +			(unsigned int)msg_len, (unsigned int)buffer->size);

Don't allow broken hardware to spam the kernel log.  Make this a
debugging message instead.

And place the check above the comment?

thanks,

greg k-h

      reply	other threads:[~2025-12-18 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18 14:43 [PATCH] misc: ibmvmc: fix buffer overflow in ibmvmc_recv_msg() Junrui Luo
2025-12-18 14:57 ` Greg Kroah-Hartman [this message]

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=2025121804-angles-driller-7c7c@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=adreznec@linux.vnet.ibm.com \
    --cc=arnd@arndb.de \
    --cc=bryantly@linux.vnet.ibm.com \
    --cc=bwarrum@linux.ibm.com \
    --cc=danisjiang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=moonafterrain@outlook.com \
    --cc=rdunlap@infradead.org \
    --cc=rituagar@linux.ibm.com \
    --cc=seroyer@linux.vnet.ibm.com \
    /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