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]
Message-ID: <e6acc89d-7d17-62ee-d67a-b78b1cdcd085@intel.com>
Date:   Sat, 8 Oct 2022 11:38:04 +0300
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Christian Löhle <CLoehle@...erstone.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Linux MMC List <linux-mmc@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCHv2 1/2] mmc: block: Remove error check of hw_reset on reset

On 7/10/22 18:42, Christian Löhle wrote:
> Before switching back to the right partition in mmc_blk_reset
> there used to be a check if hw_reset was even supported.
> This return value was removed, so there is no reason to check.
> 
> Fixes: fefdd3c91e0a ("mmc: core: Drop superfluous validations in mmc_hw|sw_reset()")
> Cc: stable@...r.kernel.org
> 
> Signed-off-by: Christian Loehle <cloehle@...erstone.com>
> ---
> -v2: Do not attempt to switch partitions if reset failed
> 
>  drivers/mmc/core/block.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index ce89611a136e..8db72cba2bbe 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -991,29 +991,27 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
>  			 int type)
>  {
>  	int err;
> +	struct mmc_blk_data *main_md = dev_get_drvdata(&host->card->dev);
> +	int part_err;
>  
>  	if (md->reset_done & type)
>  		return -EEXIST;
>  
>  	md->reset_done |= type;
>  	err = mmc_hw_reset(host->card);
> +	if (err)
> +		return err;

This could be a potential source of data corruption.

There is no guarantee that a subsequent I/O will fail just because
the reset failed.  Reading / writing the wrong partition would be
disastrous, so we should always try to get back to the correct
partition.

I haven't looked at the possibility of just flagging the partition
as invalid - need to be sure any subsequent I/O attempts still go
through a path that switches the partition.

>  	/* Ensure we switch back to the correct partition */
> -	if (err) {
> -		struct mmc_blk_data *main_md =
> -			dev_get_drvdata(&host->card->dev);
> -		int part_err;
> -
> -		main_md->part_curr = main_md->part_type;
> -		part_err = mmc_blk_part_switch(host->card, md->part_type);
> -		if (part_err) {
> -			/*
> -			 * We have failed to get back into the correct
> -			 * partition, so we need to abort the whole request.
> -			 */
> -			return -ENODEV;
> -		}
> +	main_md->part_curr = main_md->part_type;
> +	part_err = mmc_blk_part_switch(host->card, md->part_type);
> +	if (part_err) {
> +		/*
> +		 * We have failed to get back into the correct
> +		 * partition, so we need to abort the whole request.
> +		 */
> +		return -ENODEV;
>  	}
> -	return err;
> +	return 0;
>  }
>  
>  static inline void mmc_blk_reset_success(struct mmc_blk_data *md, int type)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ