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]
Date:   Tue, 1 Oct 2019 09:47:35 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Yizhuo <yzhai003@....edu>
Cc:     csong@...ucr.edu, zhiyunq@...ucr.edu,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        Shawn Guo <shawnguo@...nel.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Fabio Estevam <festevam@...il.com>,
        NXP Linux Team <linux-imx@....com>,
        Enrico Weigelt <info@...ux.net>,
        Kate Stewart <kstewart@...uxfoundation.org>,
        Stephen Boyd <swboyd@...omium.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-iio@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: adc: imx25-gcq: fix uninitialized variable usage

On Mon, 30 Sep 2019 12:53:54 -0700
Yizhuo <yzhai003@....edu> wrote:

> In function mx25_gcq_irq(), local variable "stats" could
> be uninitialized if function regmap_read() returns -EINVAL.
> However, this value is used in if statement, which is
> potentially unsafe. The same case applied to the variable
> "data" in function mx25_gcq_get_raw_value() in the same file.
> 
> Signed-off-by: Yizhuo <yzhai003@....edu>

Following similar logic to the other patch I just reviewed
for the stm32-timer-trigger, lets chase if this can happen.
In this case a clock is not provided during the regmap iomem register
and as such, the call can't actually fail.

So this one is more of a tidy up and hardening against future
problems if the code changes, than an actual fix.

Worth having, but perhaps remove the word fix from the description
unless you can find a path I've missed in which this might actually
happen as the code currently is.

One minor comment inline,

Thanks,

Jonathan
> ---
>  drivers/iio/adc/fsl-imx25-gcq.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c
> index fa71489195c6..3b1e12b7c1ac 100644
> --- a/drivers/iio/adc/fsl-imx25-gcq.c
> +++ b/drivers/iio/adc/fsl-imx25-gcq.c
> @@ -73,8 +73,12 @@ static irqreturn_t mx25_gcq_irq(int irq, void *data)
>  {
>  	struct mx25_gcq_priv *priv = data;
>  	u32 stats;
> +	int ret;
>  
> -	regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
> +	ret = regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
> +	if (ret) {

No brackets around a single line block like this.

> +		return ret;
> +	}
>  
>  	if (stats & MX25_ADCQ_SR_EOQ) {
>  		regmap_update_bits(priv->regs, MX25_ADCQ_MR,
> @@ -100,6 +104,7 @@ static int mx25_gcq_get_raw_value(struct device *dev,
>  {
>  	long timeout;
>  	u32 data;
> +	int ret;
>  
>  	/* Setup the configuration we want to use */
>  	regmap_write(priv->regs, MX25_ADCQ_ITEM_7_0,
> @@ -121,7 +126,11 @@ static int mx25_gcq_get_raw_value(struct device *dev,
>  		return -ETIMEDOUT;
>  	}
>  
> -	regmap_read(priv->regs, MX25_ADCQ_FIFO, &data);
> +	ret = regmap_read(priv->regs, MX25_ADCQ_FIFO, &data);
> +	if (ret) {
> +		dev_err(dev, "Failed to read MX25_ADCQ_FIFO.\n");
> +		return ret;
> +	}
>  
>  	*val = MX25_ADCQ_FIFO_DATA(data);
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ