mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Joshua Henderson <joshua.henderson@microchip.com>
Cc: linux-kernel@vger.kernel.org,
	Purna Chandra Mandal <purna.mandal@microchip.com>,
	linux-spi@vger.kernel.org
Subject: Re: [PATCH] spi: Fix incomplete handling of SPI_MASTER_MUST_RX/_MUST_TX
Date: Mon, 1 Feb 2016 23:17:33 +0000	[thread overview]
Message-ID: <20160201231733.GK4455@sirena.org.uk> (raw)
In-Reply-To: <1454366363-10564-1-git-send-email-joshua.henderson@microchip.com>

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]

On Mon, Feb 01, 2016 at 03:39:23PM -0700, Joshua Henderson wrote:
> From: Purna Chandra Mandal <purna.mandal@microchip.com>

> There is a BUG in the way SPI_MASTER_MUST_RX/TX is implemented which can create

Bug is a WORD like any other WORD...

> (1) spi core assigns dummy_rx buffer to transfer.rx_buf member and
> (2) passes it to lower layer for handling. and lower layer completed the
>     transfer/message in due time.
> (3) spi core deletes the buffer if no other requests pending, but
>     'transfer.rx_buf' continues to hold *stale* dummy buffer pointer.
> (4) If spi client driver (like mmc_spi) reuses the same transfer structure and
>     don't touch .rx_buf to NULL

> mmc_spi doesn't reset the ptr unless data transfer direction changes in future
> transaction(s). spi core will skip assigning new dummy buffer and underlying
> master driver will treat .rx_buf as legitimate ptr. This will result into memory
> corruption due to usage of free'd ptr.

It's not clear to me that this is the best fix, it's causing problems to
free the transfer but we could also fix that by just not freeing the
dummy data once we realize we need it unless the adaptor is freed.  That
should also be more efficient since it saves us having to allocate and
free things.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-02-01 23:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 22:39 Joshua Henderson
2016-02-01 23:17 ` Mark Brown [this message]
2016-02-05  5:00   ` Purna Chandra Mandal
2016-02-08 16:15     ` Mark Brown
2016-03-01 12:17       ` Purna Chandra Mandal

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=20160201231733.GK4455@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=joshua.henderson@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=purna.mandal@microchip.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

all inboxes | Powered by JetHome®