From: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Carl Vanderlip <quic_carlv@quicinc.com>,
Oded Gabbay <ogabbay@kernel.org>,
Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>,
Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] accel/qaic: Fix integer overflow in qaic_validate_req()
Date: Thu, 6 Mar 2025 12:12:53 -0700 [thread overview]
Message-ID: <03bfed13-c541-4a09-8330-ca3563be0f77@oss.qualcomm.com> (raw)
In-Reply-To: <820aed99-4417-4e4b-bf80-fd23c7a09dbb@stanley.mountain>
On 3/5/2025 8:53 AM, Dan Carpenter wrote:
> These are u64 variables that come from the user via
> qaic_attach_slice_bo_ioctl(). Ensure that the math doesn't have an
> integer wrapping bug.
>
> Cc: stable@vger.kernel.org
> Fixes: ff13be830333 ("accel/qaic: Add datapath")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/accel/qaic/qaic_data.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> index c20eb63750f5..cd5a31edba66 100644
> --- a/drivers/accel/qaic/qaic_data.c
> +++ b/drivers/accel/qaic/qaic_data.c
> @@ -563,7 +563,8 @@ static int qaic_validate_req(struct qaic_device *qdev, struct qaic_attach_slice_
> invalid_sem(&slice_ent[i].sem2) || invalid_sem(&slice_ent[i].sem3))
> return -EINVAL;
>
> - if (slice_ent[i].offset + slice_ent[i].size > total_size)
> + if (slice_ent[i].offset > U64_MAX - slice_ent[i].size ||
> + slice_ent[i].offset + slice_ent[i].size > total_size)
> return -EINVAL;
> }
>
I agree this is an issue that needs to be addressed. However, it seems
that overflow checking helpers exist (include/linux/overflow.h),
therefore open coding a check feels non-preferable. I think
check_add_overflow() would be the way to go. Do you agree?
-Jeff
next prev parent reply other threads:[~2025-03-06 19:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 15:53 [PATCH] accel/qaic: Fix integer overflow in qaic_validate_req() Dan Carpenter
2025-03-06 19:12 ` Jeff Hugo [this message]
2025-03-07 7:28 ` Dan Carpenter
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=03bfed13-c541-4a09-8330-ca3563be0f77@oss.qualcomm.com \
--to=jeff.hugo@oss.qualcomm.com \
--cc=dan.carpenter@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=quic_carlv@quicinc.com \
--cc=stanislaw.gruszka@linux.intel.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;
as well as URLs for NNTP newsgroup(s).