From nobody Tue Jun 16 19:41:10 2026 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 426313FBEC2 for ; Wed, 29 Apr 2026 13:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468652; cv=none; b=DErz6zkXIduoZDOcG4tGX7XyLDzI1hhxKjff11wVGt6O9LWjYRRW/jdOaKi+GP5YwqyfsgQ1SWCamm34j9jQhVxm+y7RgkxvhoPMgzy8zOsqWRW3+aMMK9TXjhPUN16/J6XLTI7AnOEYGCvLjlzdOK06hbp8qf8Y+kw0mahsXxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468652; c=relaxed/simple; bh=8zDzl40BaE6A2qSxEiS15J6sZUI2R9MUGecR7Jcykuk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ajnxChGv0hcrgVvWoYXlNEQn7UaZ+tTg140uZtmcaJdsVHcCzNhSbOflZY4fsdzjJuNUonQVgP1csOE1SMMzoNxlDxJhDX/DDCSqsXeVsXaquECwGJhWGMHL7EIcUH69PMCRwdU9AntoaO8X2tcluf6j8ZTzXDFtxw3Edlbh81c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aMj4FQhW; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aMj4FQhW" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5a2b5ea59a1so18821932e87.1 for ; Wed, 29 Apr 2026 06:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777468649; x=1778073449; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0uZhjPbSdYNEfdJ2xmxocjlnV7uXSsw+wopBLD2OHSc=; b=aMj4FQhWraoFdFq4e0CMYeXqdpmXbViqbEiBpAKpCxegKWMeHYOiLwNLfUfFbhcagj t4BDpUhu2oPxuVMjl+EfAJE467W0T0okYOgxtjkKX5JQlH6NhM9BKbqdQOn3MHCeI1Pt +4O4Rm9BnIg4zGJaBv/Pl5cHJr/Ja/ASL+F8+6YIbn12IE6juj2o31lBa0tLll9wtZgI krLksiU35BTpKt3u5rw7QDyK0+Zx2w6e9WL+WuJ/yqIhgzPYZxAI7ABtIyzidookZrgn q/hcebSbFfAT2tNeXfLNUYqFfSxZ8utPuWVHkVH30/qq5tXS9gEflSXv6Du3/ZQzJ3yG yk5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777468649; x=1778073449; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0uZhjPbSdYNEfdJ2xmxocjlnV7uXSsw+wopBLD2OHSc=; b=oOjFtHsxTAq+/C+Vgwkm1w5+7YgECNR55rxX6kfnDrgFOWLf35h2KXAcvI7vNtGYfy H4z+UlIYSgw+ID3K5kJEEigfepOrkmUrue4KGPs6BfcP17b6n5oSwSL+A1CkmWeJlXsi fNdza99pnTd0JCKxPJrtZkZrfdSyVbQd74UEcfm9sQ01VJQMg3B1ICw5Yfaz8dmcf3cO IrNbf10YqgKrMrBSVMqMS7Apx9J0aC520wg2V0j/qPAA78LGokwPNbtagVg+Wr0vaaMh a0mN8JgihxbCd8anSYIapQCOPABKXwmyIJI1PMaYCDLolz7btggHgR+Gzq/i/tsnJR1H G0Ag== X-Forwarded-Encrypted: i=1; AFNElJ/rz++eEx+RquHzC8jYa7L7zKXdKp5T5NZLT6EDCUQg0WxglVJfAIhFXaFxl2gMkJwHk2ogaBcDAd4SHEE=@vger.kernel.org X-Gm-Message-State: AOJu0YxkcK5oR8odobaz9d8jge7GP8MIGL1d4qk4zvK5xuzRrj/6Apjz AZyhuq1fnuf0ZHy8tRd1WgyWyX7SaBFjp+AspPWUp+Rsa7VjGQPecj4U X-Gm-Gg: AeBDieuUqoamrBBZLtDnCX34yVCuvi4m2X9RgZARpzpUBrhmegproiGLNeMQgBlhmZS WH6ZzMg45DnFFB+WZ1xZ7w25u/e0LLB5lRfSffch6BntXb+yddRVAH/t1G/Q1MwExMp9YyiEsTv KcXBgyFUy6r3Uko2G4LdNreMfZe0zzyDuk9CQX1+7goGrSEV0UzieaPZww0zfOjMh5UHZ/Q3gOz XBJex0swdGX2uW5ZgtLkLAJxtpyFYltHXNDU2DBL373WBOtaec9/mBG1Y3mtlkDtswbJsYXJSmu DyP6DS58q8kAqO1dqRuPJDOePciIZ+ZC6TOVg4rfvOAimzsHg2bsb1q3lG7vD4G0RDA4F+rH5db 1oWg3of2daW3wNrwUYGK6M40vMnUf4K7BJmEVhfcjFe8ZE6BnX5gnruSJXDzMDKM7nV6omuxLvo ZYj2lk5VkUhqLb/uhyXwCBiTn//QXMGqB6oyyzxGAScAwQDPh2PQ== X-Received: by 2002:a05:6512:3ca1:b0:5a2:a36f:3ef4 with SMTP id 2adb3069b0e04-5a749d1fa92mr1719854e87.31.1777468649159; Wed, 29 Apr 2026 06:17:29 -0700 (PDT) Received: from localhost.localdomain ([62.76.73.208]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a74a6f318bsm558820e87.23.2026.04.29.06.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 06:17:28 -0700 (PDT) From: Ilya Polyvyanyy To: Eugeniy.Paltsev@synopsys.com, vkoul@kernel.org Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Ilya Polyvyanyy Subject: [PATCH] dmaengine: dw-axi-dmac: fix vchan teardown races and LLI dump bounds Date: Wed, 29 Apr 2026 16:17:15 +0300 Message-ID: <20260429131718.2557247-1-il.polyvyanyy@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The channel teardown paths free descriptors/pools without synchronizing virt-dma callbacks first. If the vchan tasklet is still running, descriptor cleanup may race with callback processing and trigger use-after-free. Call vchan_synchronize() in free_chan_resources() and terminate_all() to drain pending tasklet activity before/after descriptor list cleanup. Also fix axi_chan_list_dump_lli() to iterate over desc_head->nr_hw_descs instead of the channel-wide descs_allocated counter. The old bound could exceed the current descriptor array and cause out-of-bounds access in the error-dump path. Signed-off-by: Ilya Polyvyanyy --- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/d= w-axi-dmac/dw-axi-dmac-platform.c index 4d53f077e..4c317ee82 100644 --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c @@ -553,6 +553,7 @@ static void dma_chan_free_chan_resources(struct dma_cha= n *dchan) =20 axi_chan_disable(chan); axi_chan_irq_disable(chan, DWAXIDMAC_IRQ_ALL); + vchan_synchronize(&chan->vc); =20 vchan_free_chan_resources(&chan->vc); =20 @@ -1049,9 +1050,13 @@ static void axi_chan_dump_lli(struct axi_dma_chan *c= han, static void axi_chan_list_dump_lli(struct axi_dma_chan *chan, struct axi_dma_desc *desc_head) { - int count =3D atomic_read(&chan->descs_allocated); + int count; int i; =20 + if (!desc_head || !desc_head->hw_desc) + return; + + count =3D desc_head->nr_hw_descs; for (i =3D 0; i < count; i++) axi_chan_dump_lli(chan, &desc_head->hw_desc[i]); } @@ -1206,6 +1211,7 @@ static int dma_chan_terminate_all(struct dma_chan *dc= han) spin_unlock_irqrestore(&chan->vc.lock, flags); =20 vchan_dma_desc_free_list(&chan->vc, &head); + vchan_synchronize(&chan->vc); =20 dev_vdbg(dchan2dev(dchan), "terminated: %s\n", axi_chan_name(chan)); =20 --=20 2.54.0