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 6E84F3783D0 for ; Tue, 17 Feb 2026 19:54:03 +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=1771358043; cv=none; b=gAPseHyt9Zgi6l+35a2AAlGvlg/HdBoRZMG0ywHlSYovTOpCyyYkJa895QDK4V2dJ4tZ4acQAE6rCnimGiqybd1+TmAc+mQ84Fjy5+EM/10JtHY6ZQ25yEEhB9z4owob5s6WZMB3hs+kuekmMGuVznYyRSEoIlqQRoyU1BtaFmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771358043; c=relaxed/simple; bh=+CzQjO6qTPk9ngnNPY+juCNZ6TMmFzDDdAUTAmZQ40U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ala6TcRjZH/iDBqNGXxL26hEpAU14h3XEa4sRS7rECVWkHr5/Pfo7N7VebhduCtFTNQP0jWG7HbIgM/H6JhW8dT5FVp0vRRDjpxF1+seMk9O3MAmfvrws8lkmcwwKzWV2Mfz1AwOxWxTn/3xId9v9FNbCQRwUxgE1FpjR7Df8n0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HZ1qYfVk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HZ1qYfVk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75501C4CEF7; Tue, 17 Feb 2026 19:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771358043; bh=+CzQjO6qTPk9ngnNPY+juCNZ6TMmFzDDdAUTAmZQ40U=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=HZ1qYfVkIID5T8O4wtswK8vOLnbnqnWwj1Q4Riokzte8grJTVms/U5Nzq/q4WEnx5 1NeZUSwxhzD4AkOVw+444rPs9gza2n/FhQeRR3pSk3TjBdHphDsdx7FcKZbWzH1ifi XCK7Q8lWhHrDMihaCfsLDq3bMiMN8DhkkUngsdLHW9pFmen9i52bpLvrXCwcqLIKP1 EZOGoZKoUw4q6CejUkB2wRm8qmBIprRJJevZmJleCL43IMuj1GnDgqkZKG2evgwS98 02ek1gMaVOc/U0p0texV+iTr6iWwFYRLLRr9VriMnHMzt0BbwoZbe5EzCsih5TSY9s aIevxUIB5N+bg== Message-ID: Date: Tue, 17 Feb 2026 13:54:01 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V1] accel/amdxdna: Prevent ubuf size overflow To: Lizhi Hou , ogabbay@kernel.org, quic_jhugo@quicinc.com, dri-devel@lists.freedesktop.org, maciej.falkowski@linux.intel.com Cc: linux-kernel@vger.kernel.org, max.zhen@amd.com, sonal.santan@amd.com References: <20260217192815.1784689-1-lizhi.hou@amd.com> Content-Language: en-US From: Mario Limonciello In-Reply-To: <20260217192815.1784689-1-lizhi.hou@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/17/26 1:28 PM, Lizhi Hou wrote: > The ubuf size calculation may overflow, resulting in an undersized > allocation and possible memory corruption. > > Use check_add_overflow() helpers to validate the size calculation before > allocation. > > Fixes: bd72d4acda10 ("accel/amdxdna: Support user space allocated buffer") > Signed-off-by: Lizhi Hou Reviewed-by: Mario Limonciello (AMD) > --- > drivers/accel/amdxdna/amdxdna_ubuf.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c > index 9e3b3b055caa..62a478f6b45f 100644 > --- a/drivers/accel/amdxdna/amdxdna_ubuf.c > +++ b/drivers/accel/amdxdna/amdxdna_ubuf.c > @@ -7,6 +7,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -176,7 +177,10 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev, > goto free_ent; > } > > - exp_info.size += va_ent[i].len; > + if (check_add_overflow(exp_info.size, va_ent[i].len, &exp_info.size)) { > + ret = -EINVAL; > + goto free_ent; > + } > } > > ubuf->nr_pages = exp_info.size >> PAGE_SHIFT;