From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90BB72566E9 for ; Thu, 18 Dec 2025 14:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766069873; cv=none; b=qgmwdOOue7WbhWby6+XPtUKnW4H+TrliXEAOaeo4yUJNlZRaIkgE7j9kJJWevjMk0GiGPiDALaEaxBFxl7NdFh6BteFqgmtMD7NlbDEaMrP9jwDnfKbEXnXPcLMrS0lo5caPafjOTqLegGMzIOYPn1mENzvgmmrh75d/rhRf/xI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766069873; c=relaxed/simple; bh=oumzbTHz25h+csxUC8CrD4XGr2e/dGuCxcj7Vdd32RE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LB8OyiaPNGoFogpK7EwMoIHpWMmD/L7UbrZpJ+jbapN4rMHV7AhnkKQ/izEZGgqa6wZf564nMu0DEO3AURWKEHLhXqp2tD5Ncha9HNVHCgTIc8ZPRlVuxTU8iQpvPjHnMQcq+VaxUAsfJYg+rtJUy0CprQkFWpIyIN6igkQP+AI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qwhcUb69; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qwhcUb69" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A01BFC4CEFB; Thu, 18 Dec 2025 14:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1766069873; bh=oumzbTHz25h+csxUC8CrD4XGr2e/dGuCxcj7Vdd32RE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qwhcUb69/kdYYjeG6/4oPb/LFslJCdmqYdEEnq7FLsfQtsjFXGrMGG/6VsASmlEkW r3fCkpA/iFxfr22QpTqqn0C5+N2Gwbfs1QjwxaD4nxQOb5B9gXmEEz/zwGmxBDADxu 1B24TVk+fAhr/P32a2gW2sMI/YscS12V+aJfe9mY= Date: Thu, 18 Dec 2025 15:57:49 +0100 From: Greg Kroah-Hartman To: Junrui Luo Cc: Brad Warrum , Ritu Agarwal , Arnd Bergmann , Adam Reznechek , Steven Royer , "Bryant G. Ly" , Randy Dunlap , linux-kernel@vger.kernel.org, Yuhao Jiang Subject: Re: [PATCH] misc: ibmvmc: fix buffer overflow in ibmvmc_recv_msg() Message-ID: <2025121804-angles-driller-7c7c@gregkh> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 > Reported-by: Junrui Luo > Fixes: 0eca353e7ae7 ("misc: IBM Virtual Management Channel Driver (VMC)") > Signed-off-by: Junrui Luo > --- > 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