From: Jon Hunter Subject: Re: [PATCH v5 01/14] dmaengine: tegra-apb: Fix use-after-free Date: Wed, 29 Jan 2020 10:56:15 +0000 Message-ID: <858021de-62fd-2d21-7152-42af4e3a04b2@nvidia.com> References: <20200123230325.3037-1-digetx@gmail.com> <20200123230325.3037-2-digetx@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20200123230325.3037-2-digetx@gmail.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Dmitry Osipenko , Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-tegra@vger.kernel.org On 23/01/2020 23:03, Dmitry Osipenko wrote: > I was doing some experiments with I2C and noticed that Tegra APB DMA > driver crashes sometime after I2C DMA transfer termination. The crash > happens because tegra_dma_terminate_all() bails out immediately if pending > list is empty, thus it doesn't release the half-completed descriptors > which are getting re-used before ISR tasklet kicks-in. > > tegra-i2c 7000c400.i2c: DMA transfer timeout > elants_i2c 0-0010: elants_i2c_irq: failed to read data: -110 > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 142 at lib/list_debug.c:45 __list_del_entry_valid+0x45/0xac > list_del corruption, ddbaac44->next is LIST_POISON1 (00000100) > Modules linked in: > CPU: 0 PID: 142 Comm: kworker/0:2 Not tainted 5.5.0-rc2-next-20191220-00175-gc3605715758d-dirty #538 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events_freezable_power_ thermal_zone_device_check > [] (unwind_backtrace) from [] (show_stack+0x11/0x14) > [] (show_stack) from [] (dump_stack+0x85/0x94) > [] (dump_stack) from [] (__warn+0xc1/0xc4) > [] (__warn) from [] (warn_slowpath_fmt+0x61/0x78) > [] (warn_slowpath_fmt) from [] (__list_del_entry_valid+0x45/0xac) > [] (__list_del_entry_valid) from [] (tegra_dma_tasklet+0x5b/0x154) > [] (tegra_dma_tasklet) from [] (tasklet_action_common.constprop.0+0x41/0x7c) > [] (tasklet_action_common.constprop.0) from [] (__do_softirq+0xd3/0x2a8) > [] (__do_softirq) from [] (irq_exit+0x7b/0x98) > [] (irq_exit) from [] (__handle_domain_irq+0x45/0x80) > [] (__handle_domain_irq) from [] (gic_handle_irq+0x45/0x7c) > [] (gic_handle_irq) from [] (__irq_svc+0x65/0x94) > Exception stack(0xde2ebb90 to 0xde2ebbd8) > > Cc: > Signed-off-by: Dmitry Osipenko > --- > drivers/dma/tegra20-apb-dma.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c > index 3a45079d11ec..319f31d27014 100644 > --- a/drivers/dma/tegra20-apb-dma.c > +++ b/drivers/dma/tegra20-apb-dma.c > @@ -756,10 +756,6 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) > bool was_busy; > > spin_lock_irqsave(&tdc->lock, flags); > - if (list_empty(&tdc->pending_sg_req)) { > - spin_unlock_irqrestore(&tdc->lock, flags); > - return 0; > - } > > if (!tdc->busy) > goto skip_dma_stop; Acked-by: Jon Hunter I think that we should mark this one for stable. Cheers Jon -- nvpublic