DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jyothi Kumar Seerapu" <jyothi.seerapu@oss.qualcomm.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH 1/2] dmaengine: qcom-gpi: Add I2C High-Speed mode configuration support
Date: Mon, 24 Aug 2026 11:36:52 +0000	[thread overview]
Message-ID: <20260824113653.402771F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-i2c-hs-v1-1-8dd94e5c6113@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Heap Buffer Overflow and DMA Address Corruption in I2C High-Speed mode due to insufficient MAX_TRE
--

--- Patch [1]: [PATCH 1/2] dmaengine: qcom-gpi: Add I2C High-Speed mode configuration support ---
commit 0c2b77de6fa90756115b4394bd0db3e62bed9d2a
Author: Jyothi Kumar Seerapu <jyothi.seerapu@oss.qualcomm.com>

dmaengine: qcom-gpi: Add I2C High-Speed mode configuration support

Add support in the Qualcomm GPI DMA engine to configure I2C High-Speed (HS)
mode transfers. This introduces support for the CONFIG1 Transfer Ring Element
(TRE) to convey HS-specific timing parameters.

> --- a/drivers/dma/qcom/gpi.c
> +++ b/drivers/dma/qcom/gpi.c
[ ... ]
> @@ -1631,7 +1637,7 @@ static int gpi_create_i2c_tre(struct gchan *chan, struct gpi_desc *desc,
>  	struct gpi_tre *tre;
>  	unsigned int i;
>  
> -	/* first create config tre if applicable */
> +	/* first create config0 tre if applicable */
>  	if (i2c->set_config) {
>  		tre = &desc->tre[tre_idx];
>  		tre_idx++;
[ ... ]
> +	/* Create CONFIG1 TRE if requested */
> +	if (i2c->set_config1) {
> +		tre = &desc->tre[tre_idx];
> +		tre_idx++;
[ ... ]
>  	/* create the GO tre for Tx */
> -	if (i2c->op == I2C_WRITE) {
> +	if (i2c->op == I2C_WRITE || i2c->op == I2C_HS_WRITE) {
[ ... ]
>  		tre = &desc->tre[tre_idx];
>  		tre_idx++;
[ ... ]
> -	if (i2c->op == I2C_READ || i2c->multi_msg == false) {
> +	if (i2c->op == I2C_READ || i2c->op == I2C_HS_READ || i2c->multi_msg == false) {
>  		/* create the DMA TRE */
>  		tre = &desc->tre[tre_idx];
>  		tre_idx++;
>
>  		address = sg_dma_address(sgl);
>  		tre->dword[0] = lower_32_bits(address);

[Severity: High]
When I2C High-Speed mode is used with both set_config and set_config1,
can this cause an out-of-bounds write to the tre array?

Looking at struct gpi_desc, the tre array is statically sized by MAX_TRE,
which is defined as 3:

#define MAX_TRE 3

struct gpi_desc {
        ...
        struct gpi_tre tre[MAX_TRE];
        u32 num_tre;
};

If we generate CONFIG0, CONFIG1, GO, and DMA TREs, tre_idx will reach 3
here. Writing to desc->tre[3] would overflow the array and overwrite the
adjacent num_tre field.

Later, gpi_prep_slave_sg() sets gpi_desc->num_tre = 4, which would
overwrite the first 4 bytes of the newly written DMA TRE, potentially
causing an IOMMU fault or bus error when the hardware attempts the transfer.

Should MAX_TRE be increased to accommodate the new CONFIG1 TRE?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-i2c-hs-v1-0-8dd94e5c6113@oss.qualcomm.com?part=1

  reply	other threads:[~2026-08-24 11:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 11:25 [PATCH 0/2] i2c: Add I2C High-Speed mode support for qcom-geni Jyothi Kumar Seerapu
2026-08-24 11:25 ` [PATCH 1/2] dmaengine: qcom-gpi: Add I2C High-Speed mode configuration support Jyothi Kumar Seerapu
2026-08-24 11:36   ` sashiko-bot [this message]
2026-08-25 20:31     ` Frank Li
2026-08-26  6:22       ` Jyothi Kumar Seerapu
2026-08-24 11:25 ` [PATCH 2/2] i2c: qcom-geni: Add support for I2C High-Speed mode Jyothi Kumar Seerapu
2026-08-24 11:39   ` sashiko-bot

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=20260824113653.402771F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=jyothi.seerapu@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox