Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp677964ybh; Tue, 10 Mar 2020 06:19:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvecMcSrzaCzLG3WtDfXZaVKJoHfdfhtf+SIfukSs4nk1pGbcfyO7syiS3DxkaMjS5qGK1q X-Received: by 2002:aca:3354:: with SMTP id z81mr1122819oiz.129.1583846383335; Tue, 10 Mar 2020 06:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583846383; cv=none; d=google.com; s=arc-20160816; b=UCAB7Gqux+nTtg0pbTtY5T936ktdDtFxfod/2NWpfPHzocfxKNoOv4GsgNDqs7JWDq j60Y9cEdTRk0AYHr3cFeydIM7YAUpw89OYQkVoB+9V0xAV9zwPp/mSQCRH41XQjKPinS oSCCHYm34uLw0Sj/2z3611H3B07pBdV/lxLqgtFuTRApMA/P8htxWiNp+8UCMAe/dr/o 8+KA9msT7s8LZc/vvsKcbbKG7OhPlFL+J6z16TBs/X9rZpT+fZujLmSxouZ3BgLraGxC 9NXDhwnm1ox/BfTgT9VOpo1yRK2fbEQGnuILUrDNlilWjKYu+ME8Zp3lRQrd9M7ldOZ7 w2+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=06qalX7Q70N7QQBXBYDI5ohOmJsB3WbK0/zgXYPwH3U=; b=u9YCVjIzW4CAFmebBwZikAP9K3NMK3otOvArorBUDoScM9Rmilu1DcBs+9zUNuwouL bjrMoerThAkX+m1kVkGCiLwSUqH+QlQYqnbacnACs5ki18I+kgo6GWSBp3XqSxQC57CE 5tWI5dDhEXCy4OJl+pdnBoh7oHnO55MZCHzPbZiWDLUekHrqy2Y07fgqqxY9nZ6qB2Jo B2g05hyTZcAe02T5dShdfjahmce0CVV3xCfKDGa+Zl4vT41EkqayuLzip2DpYqUyaDHv aZueXTnJCBlozhh+iw/rMj6nR/+ojzYcPLxBDaYXN0s0Oyqv0wD8yVPYLUoloY23Cl+b AHug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xqJbxuvu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si5162504oij.113.2020.03.10.06.19.30; Tue, 10 Mar 2020 06:19:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xqJbxuvu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729933AbgCJNSw (ORCPT + 99 others); Tue, 10 Mar 2020 09:18:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:58568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730618AbgCJNKG (ORCPT ); Tue, 10 Mar 2020 09:10:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E982A246DE; Tue, 10 Mar 2020 13:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583845805; bh=jQRkvTTSvmorzupsnApKvUN8T93chrRBwJoSMoNe3Ko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqJbxuvuB5ocStvZuJ6x9B/wQyt8cxbJ8GhTjuQ7D3JwUse8Pjz6AaM427KfbS5HP Box3fErghs9PDp8Sxq9M6yd5w75LEZZy3+CIytT9KMd9exal2tDkXe2mDZKmYHaMHB m/Lu7F+a0tU4eMW6xOhYeVRrJ31ospJXIe8sts28= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Jon Hunter , Vinod Koul Subject: [PATCH 4.14 107/126] dmaengine: tegra-apb: Fix use-after-free Date: Tue, 10 Mar 2020 13:42:08 +0100 Message-Id: <20200310124210.438533035@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310124203.704193207@linuxfoundation.org> References: <20200310124203.704193207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko commit 94788af4ed039476ff3527b0e6a12c1dc42cb022 upstream. 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, and 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) Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter Cc: Link: https://lore.kernel.org/r/20200209163356.6439-2-digetx@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/tegra20-apb-dma.c | 4 ---- 1 file changed, 4 deletions(-) --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -755,10 +755,6 @@ static int tegra_dma_terminate_all(struc 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;