lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Mar 2022 20:44:09 +0200
From:   "andriy.shevchenko@...ux.intel.com" 
        <andriy.shevchenko@...ux.intel.com>
To:     Christian Löhle <CLoehle@...erstone.com>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-mmc@...r.kernel.org" <linux-mmc@...r.kernel.org>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Avri Altman <Avri.Altman@....com>,
        "david-b@...bell.net" <david-b@...bell.net>
Subject: Re: [PATCH] mmc: block: Check for errors after write on SPI

On Tue, Mar 22, 2022 at 04:21:34PM +0000, Christian Löhle wrote:
> Introduce a SEND_STATUS check for writes through SPI to not mark
> an unsuccessful write as successful.
> 
> Since SPI SD/MMC does not have states, after a write, the card will
> just hold the line LOW until it is ready again. The driver marks the
> write therefore as completed as soon as it reads something other than
> all zeroes.
> The driver does not distinguish from a card no longer signalling busy
> and it being disconnected (and the line being pulled-up by the host).
> This lead to writes being marked as successful when disconnecting
> a busy card.
> Now the card is ensured to be still connected by an additional CMD13,
> just like non-SPI is ensured to go back to TRAN state.
> 
> While at it and since we already poll for the post-write status anyway,
> we might as well check for SPIs error bits (any of them).
> 
> The disconnecting card problem is reproducable for me after continuous
> write activity and randomly disconnecting, around every 20-50 tries
> on SPI DS for some card.

...

> +	if (mmc_host_is_spi(card->host)) {
> +		u32 status = 0;

> +		err = __mmc_send_status(card, &status, 0);

> +		/* All R1 and R2 bits of SPI are errors in our case */
> +		if (status)
> +			err = err ? err : -EIO;

I would use either this:

		if (err || status) {
			mqrq->brq.data.bytes_xfered = 0;

			if (err)
				return err;
			return -EIO;
		}

		return 0;

or at least this:

			err = err ?: -EIO;

or even this:

		if (!err && status)
			err = -EIO;

(Personally I would choose the first option)


> +		if (err)
> +			mqrq->brq.data.bytes_xfered = 0;
> +		return err;
> +	}

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ