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] [day] [month] [year] [list]
Message-ID: <CAPDyKFpQxexAt=NZvz4JQCxpf-Vn_C_ZjPOp=2V9GTOduRp7-Q@mail.gmail.com>
Date:   Wed, 19 Oct 2016 15:16:45 +0200
From:   Ulf Hansson <ulf.hansson@...aro.org>
To:     Maxime Ripard <maxime.ripard@...e-electrons.com>
Cc:     linux-mmc <linux-mmc@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Hans de Goede <hdegoede@...hat.com>,
        Chen-Yu Tsai <wens@...e.org>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] mmc: sunxi: Prevent against null dereference for vmmc

On 19 October 2016 at 14:36, Maxime Ripard
<maxime.ripard@...e-electrons.com> wrote:
> VMMC is an optional regulator, which means that mmc_regulator_get_supply
> will only return an error in case of a deferred probe, but not when the
> regulator is not set in the DT.
>
> However, the sunxi driver assumes that VMMC is always there, and doesn't
> check the value of the regulator pointer before using it, which obviously
> leads to a (close to) null pointer dereference.
>
> Add proper checks to prevent that.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@...e-electrons.com>
> ---
>  drivers/mmc/host/sunxi-mmc.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> index c0a5c676d0e8..45a051e7d650 100644
> --- a/drivers/mmc/host/sunxi-mmc.c
> +++ b/drivers/mmc/host/sunxi-mmc.c
> @@ -822,10 +822,16 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>                 break;
>
>         case MMC_POWER_UP:
> -               host->ferror = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,
> -                                                    ios->vdd);
> -               if (host->ferror)
> -                       return;
> +               if (!IS_ERR(mmc->supply.vmmc)) {
> +                       host->ferror = mmc_regulator_set_ocr(mmc,
> +                                                            mmc->supply.vmmc,
> +                                                            ios->vdd);
> +                       if (host->ferror) {
> +                               dev_err(mmc_dev(mmc),
> +                                       "failed to enable vmmc\n");

The print here is already taken care of by mmc_regulator_set_ocr()

> +                               return;
> +                       }
> +               }
>
>                 if (!IS_ERR(mmc->supply.vqmmc)) {
>                         host->ferror = regulator_enable(mmc->supply.vqmmc);
> @@ -847,7 +853,9 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>         case MMC_POWER_OFF:
>                 dev_dbg(mmc_dev(mmc), "power off!\n");
>                 sunxi_mmc_reset_host(host);
> -               mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
> +               if (!IS_ERR(mmc->supply.vmmc))
> +                       mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
> +
>                 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled)
>                         regulator_disable(mmc->supply.vqmmc);
>                 host->vqmmc_enabled = false;
> --
> 2.9.3
>

Otherwise this looks good to me!

Kind regards
Uffe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ