All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Sven Van Asbroeck <thesven73@gmail.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Michal Simek <michal.simek@xilinx.com>,
	Manish Narani <manish.narani@xilinx.com>,
	linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] iio: adc: xilinx: fix potential use-after-free on remove
Date: Sat, 16 Mar 2019 15:47:58 +0000	[thread overview]
Message-ID: <20190316154758.27c59b82@archlinux> (raw)
In-Reply-To: <20190310185826.25916-1-TheSven73@gmail.com>

On Sun, 10 Mar 2019 14:58:24 -0400
Sven Van Asbroeck <thesven73@gmail.com> wrote:

> When cancel_delayed_work() returns, the delayed work may still
> be running. This means that the core could potentially free
> the private structure (struct xadc) while the delayed work
> is still using it. This is a potential use-after-free.
> 
> Fix by calling cancel_delayed_work_sync(), which waits for
> any residual work to finish before returning.
> 
> Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
This appears 'obviously correct' to me so I'll apply it to the fixes
togreg branch of iio.git and mark it for stable.

However I won't be sending a pull request for that branch until at
least next weekend, so if anyone more familiar with the hardware
has a chance to take a look that would be great.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/xilinx-xadc-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
> index 3f6be5ac049a..1960694e8007 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -1320,7 +1320,7 @@ static int xadc_remove(struct platform_device *pdev)
>  	}
>  	free_irq(xadc->irq, indio_dev);
>  	clk_disable_unprepare(xadc->clk);
> -	cancel_delayed_work(&xadc->zynq_unmask_work);
> +	cancel_delayed_work_sync(&xadc->zynq_unmask_work);
>  	kfree(xadc->data);
>  	kfree(indio_dev->channels);
>  


WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: Sven Van Asbroeck <thesven73@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, Michal Simek <michal.simek@xilinx.com>,
	linux-kernel@vger.kernel.org,
	Manish Narani <manish.narani@xilinx.com>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Hartmut Knaack <knaack.h@gmx.de>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/3] iio: adc: xilinx: fix potential use-after-free on remove
Date: Sat, 16 Mar 2019 15:47:58 +0000	[thread overview]
Message-ID: <20190316154758.27c59b82@archlinux> (raw)
In-Reply-To: <20190310185826.25916-1-TheSven73@gmail.com>

On Sun, 10 Mar 2019 14:58:24 -0400
Sven Van Asbroeck <thesven73@gmail.com> wrote:

> When cancel_delayed_work() returns, the delayed work may still
> be running. This means that the core could potentially free
> the private structure (struct xadc) while the delayed work
> is still using it. This is a potential use-after-free.
> 
> Fix by calling cancel_delayed_work_sync(), which waits for
> any residual work to finish before returning.
> 
> Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
This appears 'obviously correct' to me so I'll apply it to the fixes
togreg branch of iio.git and mark it for stable.

However I won't be sending a pull request for that branch until at
least next weekend, so if anyone more familiar with the hardware
has a chance to take a look that would be great.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/xilinx-xadc-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
> index 3f6be5ac049a..1960694e8007 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -1320,7 +1320,7 @@ static int xadc_remove(struct platform_device *pdev)
>  	}
>  	free_irq(xadc->irq, indio_dev);
>  	clk_disable_unprepare(xadc->clk);
> -	cancel_delayed_work(&xadc->zynq_unmask_work);
> +	cancel_delayed_work_sync(&xadc->zynq_unmask_work);
>  	kfree(xadc->data);
>  	kfree(indio_dev->channels);
>  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-03-16 15:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-10 18:58 [PATCH 1/3] iio: adc: xilinx: fix potential use-after-free on remove Sven Van Asbroeck
2019-03-10 18:58 ` Sven Van Asbroeck
2019-03-10 18:58 ` [PATCH 2/3] iio: adc: xilinx: fix potential use-after-free on probe Sven Van Asbroeck
2019-03-10 18:58   ` Sven Van Asbroeck
2019-03-16 15:49   ` Jonathan Cameron
2019-03-16 15:49     ` Jonathan Cameron
2019-03-10 18:58 ` [PATCH 3/3] iio: adc: xilinx: prevent touching unclocked h/w on remove Sven Van Asbroeck
2019-03-10 18:58   ` Sven Van Asbroeck
2019-03-16 15:51   ` Jonathan Cameron
2019-03-16 15:51     ` Jonathan Cameron
2019-03-17 16:07     ` Sven Van Asbroeck
2019-03-17 16:07       ` Sven Van Asbroeck
2019-03-16 15:47 ` Jonathan Cameron [this message]
2019-03-16 15:47   ` [PATCH 1/3] iio: adc: xilinx: fix potential use-after-free " Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190316154758.27c59b82@archlinux \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manish.narani@xilinx.com \
    --cc=michal.simek@xilinx.com \
    --cc=pmeerw@pmeerw.net \
    --cc=thesven73@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.