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: <CAPDyKFpCPLCxp54yjBAaLz2tJK6Ouk-ikpvs9uby7aXnic=U7Q@mail.gmail.com>
Date: Thu, 19 Jun 2025 13:20:07 +0200
From: Ulf Hansson <ulf.hansson@...aro.org>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: Chaotian Jing <chaotian.jing@...iatek.com>, Matthias Brugger <matthias.bgg@...il.com>, 
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, Tomasz Figa <tfiga@...omium.org>, 
	Sergey Senozhatsky <senozhatsky@...omium.org>, linux-mmc@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
	linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH] mtk-sd: Prevent memory corruption from DMA map failure

On Thu, 12 Jun 2025 at 13:26, Masami Hiramatsu (Google)
<mhiramat@...nel.org> wrote:
>
> From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
>
> If msdc_prepare_data() fails to map the DMA region, the request is
> not prepared for data receiving, but msdc_start_data() proceeds
> the DMA with previous setting.
> Since this will lead a memory corruption, we have to stop the
> request operation soon after the msdc_prepare_data() fails to
> prepare it.
>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>

Applied to fixes and by adding a fixes/stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/mtk-sd.c |   17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 3594010bc229..56b4999fe58f 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -834,6 +834,11 @@ static void msdc_prepare_data(struct msdc_host *host, struct mmc_data *data)
>         }
>  }
>
> +static bool msdc_data_prepared(struct mmc_data *data)
> +{
> +       return data->host_cookie & MSDC_PREPARE_FLAG;
> +}
> +
>  static void msdc_unprepare_data(struct msdc_host *host, struct mmc_data *data)
>  {
>         if (data->host_cookie & MSDC_ASYNC_FLAG)
> @@ -1466,8 +1471,18 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq)
>         WARN_ON(!host->hsq_en && host->mrq);
>         host->mrq = mrq;
>
> -       if (mrq->data)
> +       if (mrq->data) {
>                 msdc_prepare_data(host, mrq->data);
> +               if (!msdc_data_prepared(mrq->data)) {
> +                       /*
> +                        * Failed to prepare DMA area, fail fast before
> +                        * starting any commands.
> +                        */
> +                       mrq->cmd->error = -ENOSPC;
> +                       mmc_request_done(mmc_from_priv(host), mrq);
> +                       return;
> +               }
> +       }
>
>         /* if SBC is required, we have HW option and SW option.
>          * if HW option is enabled, and SBC does not have "special" flags,
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ