From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221026; b=uzKJIT9ZcCrLuQ/6/lrZAj81TKV84cyU5GfReqsEhExsUGLYMEoKb2AFMRPcu4XfafQj HWyOqcMtOyY+laBpZ+ubLAndMrstz8F2RVi64tEFt+1LbDHzIvu70xdSnFHl1l+rtPYJS xYswciVQFBAkdtcM2Y7W9yN338pKvCHBuOJvGl4KYkUJ5XjWSHKJhbPdKiFTR0u0XPDW6 IkZW+k3TMdAmblnQTP/O9tOrNH7c8oKiDHnBr2nW1Hc2OYOfzQGaPivsS84hmFB3Vo6Ho g6I/qSJ7ZwwiKX+y8j0W93ek4x359w/d6iFiiQSpIDirghEKbGK4uI40p0F2cbXnyXw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221026; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=YOcuadv4ghUggPi57zjd9o5pNBiCoZcLoV2EFIZyX8o=; b=JSsTyH9UwS4WyMY3E7vzWg1gYPZUCONgZ9Kxy0ncYv9m22iG2OHhu7l7OSCmsMIJ+pS0 kC4Ef2jxW9YIK37qCJERAluWaG0K/5/oRy/wJc+PdMGATjHyb3FhMpnRslkNyaLeIjzay YvbJ+E3IJ0ih9TT0AYAnTbXBT0bISMk8667vxN+OGS0eJieRTdQsErzklK4H/VPnYRsTI wOiV++2rOrvZ1JI9Y9UaKuKqy4IZ3TPAM0o6901BbH4MC+gh3kkeGjAeb00tLbXbCFCJa jHnptLJeaOR0LxpbWVUXqJ4d4E8laUGvrpdHjxsCvZRP4UyN663j6OsFRqss0Ggc73w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nXUYVom1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6626960A260A for ; Wed, 2 Dec 2026 14:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nXUYVom1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A02A41F0093B; Wed, 2 Dec 2026 14:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221026; bh=YOcuadv4ghUggPi57zjd9o5pNBiCoZcLoV2EFIZyX8o=; h=Subject:To:Cc:From:Date; b=nXUYVom1y6BMNw+94dNndAAC6l+oEqBJsGKHTVFcthPNtGO4j2ANmcxamAGZnomCY gV7EO+kcgX482MnHT9DATwcgvNL6DnjePZZ5j8c1v8pLs3aL8rco4Fw3WTrlFCSLny qh5HK5o7crjFJpqo4WjDAghrX/vzRKmTcqIr7rpk= Subject: FAILED: patch "[PATCH] dma: swiotlb: Round restricted DMA pool size down to" failed to apply to 6.1-stable tree To: m.szyprowski@samsung.com,gkobakhi@asu.edu,mhklinux@outlook.com Cc: From: Date: Wed, 02 Dec 2026 14:00:24 +0100 Message-ID: <2026120224-send-each-3f44@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 5b4b87935bf9c6c81b603558c2e167fc27c22a1b # git commit -s git send-email --to '' --in-reply-to '2026120224-send-each-3f44@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 5b4b87935bf9c6c81b603558c2e167fc27c22a1b Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 3 Nov 2026 16:50:15 +0100 Subject: [PATCH] dma: swiotlb: Round restricted DMA pool size down to IO_TLB_SEGSIZE All other paths creating a swiotlb pool ensure that nslabs is a multiple of IO_TLB_SEGSIZE, and the swiotlb code relies on that. Since commit 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization") a restricted pool can have an arbitrary size taken from the device tree. If the pool size is not a multiple of IO_TLB_SEGSIZE, the last segment is partial and swiotlb_release_slots() reads mem->slots[index + nslabs], which is one past the end of the slots array when the freed buffer ends at the end of the pool: BUG: KASAN: slab-out-of-bounds in swiotlb_release_slots Read of size 2 Round the pool size down to a multiple of IO_TLB_SEGSIZE, wasting a bit of memory, and warn about it. Reported-by: Giorgi Kobakhia Closes: https://lore.kernel.org/all/20261026032007.1957949-1-gkobakhi@asu.edu/ Fixes: 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization") CC: stable@vger.kernel.org Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20261103155016.1107958-1-m.szyprowski@samsung.com Signed-off-by: Marek Szyprowski diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index db731f7891b7..9b0bc272dd82 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -2012,6 +2012,19 @@ static int rmem_swiotlb_device_init(struct reserved_mem *rmem, mem = rmem->priv; if (!mem) { struct io_tlb_pool *pool; + unsigned long aligned_nslabs = ALIGN_DOWN(nslabs, IO_TLB_SEGSIZE); + + if (aligned_nslabs != nslabs) { + dev_warn(dev, "Restricted DMA pool size %zu is not a multiple of %lu, rounding down to %lu bytes\n", + (size_t)rmem->size, + (unsigned long)IO_TLB_SEGSIZE << IO_TLB_SHIFT, + aligned_nslabs << IO_TLB_SHIFT); + nslabs = aligned_nslabs; + } + if (!nslabs) { + dev_err(dev, "Restricted DMA pool is too small\n"); + return -EINVAL; + } mem = kzalloc_obj(*mem); if (!mem) @@ -2039,7 +2052,7 @@ static int rmem_swiotlb_device_init(struct reserved_mem *rmem, mem->cc_shared = true; ret = set_memory_decrypted((unsigned long)phys_to_virt(rmem->base), - rmem->size >> PAGE_SHIFT); + (nslabs << IO_TLB_SHIFT) >> PAGE_SHIFT); if (ret) { dev_err(dev, "Failed to decrypt restricted DMA pool\n"); kfree(pool->areas);