All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Gabor Juhos <j4g8y7@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	 Md Sadre Alam <quic_mdalam@quicinc.com>,
	 Varadarajan Narayanan <quic_varada@quicinc.com>,
	 Sricharan Ramabadhran <quic_srichara@quicinc.com>,
	 Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	 linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org,
	 linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Lakshmi Sowjanya D <quic_laksd@quicinc.com>
Subject: Re: [PATCH v2 2/2] mtd: nand: qpic_common: prevent out of bounds access of BAM arrays
Date: Mon, 02 Jun 2025 15:53:08 +0200	[thread overview]
Message-ID: <87iklep7wb.fsf@bootlin.com> (raw)
In-Reply-To: <20250529-qpic-snand-avoid-mem-corruption-v2-2-2f0d13afc7d2@gmail.com> (Gabor Juhos's message of "Thu, 29 May 2025 19:25:11 +0200")

Hello,

On 29/05/2025 at 19:25:11 +02, Gabor Juhos <j4g8y7@gmail.com> wrote:

> The common QPIC code does not do any boundary checking when it handles
> the command elements and scatter gater list arrays of a BAM transaction,
> thus it allows to access out of bounds elements in those.
>
> Although it is the responsibility of the given driver to allocate enough
> space for all possible BAM transaction variations, however there can be
> mistakes in the driver code which can lead to hidden memory corruption
> issues which are hard to debug.
>
> This kind of problem has been observed during testing the 'spi-qpic-snand'
> driver. Although the driver has been fixed with a preceding patch, but it
> still makes sense to reduce the chance of having such errors again later.
>
> In order to prevent such errors, change the qcom_alloc_bam_transaction()
> function to store the number of elements of the arrays in the
> 'bam_transaction' strucutre during allocation. Also, add sanity checks to
> the qcom_prep_bam_dma_desc_{cmd,data}() functions to avoid using out of
> bounds indices for the arrays.
>
> Tested-by: Lakshmi Sowjanya D <quic_laksd@quicinc.com>     # on SDX75
> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>

I'm fine with this patch going through spi,

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Gabor Juhos <j4g8y7@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	 Md Sadre Alam <quic_mdalam@quicinc.com>,
	 Varadarajan Narayanan <quic_varada@quicinc.com>,
	 Sricharan Ramabadhran <quic_srichara@quicinc.com>,
	 Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	 linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org,
	 linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Lakshmi Sowjanya D <quic_laksd@quicinc.com>
Subject: Re: [PATCH v2 2/2] mtd: nand: qpic_common: prevent out of bounds access of BAM arrays
Date: Mon, 02 Jun 2025 15:53:08 +0200	[thread overview]
Message-ID: <87iklep7wb.fsf@bootlin.com> (raw)
In-Reply-To: <20250529-qpic-snand-avoid-mem-corruption-v2-2-2f0d13afc7d2@gmail.com> (Gabor Juhos's message of "Thu, 29 May 2025 19:25:11 +0200")

Hello,

On 29/05/2025 at 19:25:11 +02, Gabor Juhos <j4g8y7@gmail.com> wrote:

> The common QPIC code does not do any boundary checking when it handles
> the command elements and scatter gater list arrays of a BAM transaction,
> thus it allows to access out of bounds elements in those.
>
> Although it is the responsibility of the given driver to allocate enough
> space for all possible BAM transaction variations, however there can be
> mistakes in the driver code which can lead to hidden memory corruption
> issues which are hard to debug.
>
> This kind of problem has been observed during testing the 'spi-qpic-snand'
> driver. Although the driver has been fixed with a preceding patch, but it
> still makes sense to reduce the chance of having such errors again later.
>
> In order to prevent such errors, change the qcom_alloc_bam_transaction()
> function to store the number of elements of the arrays in the
> 'bam_transaction' strucutre during allocation. Also, add sanity checks to
> the qcom_prep_bam_dma_desc_{cmd,data}() functions to avoid using out of
> bounds indices for the arrays.
>
> Tested-by: Lakshmi Sowjanya D <quic_laksd@quicinc.com>     # on SDX75
> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>

I'm fine with this patch going through spi,

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2025-06-02 13:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 17:25 [PATCH v2 0/2] spi: spi-qpic-snand: avoid memory corruption Gabor Juhos
2025-05-29 17:25 ` Gabor Juhos
2025-05-29 17:25 ` [PATCH v2 1/2] spi: spi-qpic-snand: reallocate BAM transactions Gabor Juhos
2025-05-29 17:25   ` Gabor Juhos
2025-05-29 17:25 ` [PATCH v2 2/2] mtd: nand: qpic_common: prevent out of bounds access of BAM arrays Gabor Juhos
2025-05-29 17:25   ` Gabor Juhos
2025-05-30  8:56   ` Bryan O'Donoghue
2025-05-30  8:56     ` Bryan O'Donoghue
2025-05-30 11:07     ` Gabor Juhos
2025-05-30 11:07       ` Gabor Juhos
2025-06-02 13:54       ` Miquel Raynal
2025-06-02 13:54         ` Miquel Raynal
2025-06-03  9:16         ` Gabor Juhos
2025-06-03  9:16           ` Gabor Juhos
2025-06-02 13:53   ` Miquel Raynal [this message]
2025-06-02 13:53     ` Miquel Raynal

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=87iklep7wb.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=j4g8y7@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=quic_laksd@quicinc.com \
    --cc=quic_mdalam@quicinc.com \
    --cc=quic_srichara@quicinc.com \
    --cc=quic_varada@quicinc.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.