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=1796221015; b=O4m4VB998QI+rmIQnoxCObj/T+5GJRYeouLASQNwodxNxpHKcDOmSKr7pvgDhLKbYgoy vE4CpPBGXrBE+w3sozDLjypwXdvE7qQl1689iiYuH9bRceHsvD+QObMBe6Jrgl+d2fX+T lzQx7CUba/L6kqGn2oWcAvmxBgZku0o6h1iCQ81lT1L60YtqKR1p3zBHLo3i5kN+0x9Qd 1eWwrlDpMlfjyDhXl6KxqGA0PVwdXmJAzLXti6OCGbmD6wbU1EyB42j6dSfYN9kGvKGwM B0QGbINQay39jn4jx2MwcipByMz8JLKNodEro8q5a0lGGZ3bhk5GCdBwh9o2rS5i8zA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221015; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=qeO0wzaO/UiGT8YlKu7mp21selV/uxbm0Ke1OJMLeDQ=; b=I1IhZIoBspwmbEWNfK60dEOC5P2VA5/HyUVkVCq5ChxWekqLgrlkmBLes28HnCCELIZR XkXm3NENAFo8EXDpoc9nyqJcuVd0RWQPhutO3+LUXWasUcShPt4o+LOWax29SjzvieAoH Dg2i6d1q9RfO2GygrH2ocvHe8Jj0HlMxYsNJTiwhkglOgnoCeY8KDIA+9akzaCQaBmtUr IW7eF6GD6yNlHZkC8+n6ALuYfVnLjy4JN164Tk2pcpbSFTIEsQ0XgaKH3lUEOYOFK7ibe x/ua4tFCHCKMpAz9VL4y96alrrGcU/DYNRNonIFuizSrScBkwlXaU614+ZVEtwJHGrg== 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=yd1EbzN4; 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 B9579606A33B for ; Wed, 2 Dec 2026 14:16:55 +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=yd1EbzN4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BE271F01578; Wed, 2 Dec 2026 14:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221015; bh=qeO0wzaO/UiGT8YlKu7mp21selV/uxbm0Ke1OJMLeDQ=; h=Subject:To:Cc:From:Date; b=yd1EbzN4wIa5e6GFtPFKY924fgt+M05+nwLq7J88yJHhnwPLnSNf3lL+Ygl3qgg3I icwuNJDIervJN0RlCzDoSTOp2Hc4+dbDD2eGxRWUUCe+KwfGtCUie7L3Ty+ziPJ+er 9bVmNEdw0fBH+jH/5dMiMoRSVXGC0UFL/c+Ov49w= Subject: FAILED: patch "[PATCH] dma: swiotlb: Round restricted DMA pool size down to" failed to apply to 6.12-stable tree To: m.szyprowski@samsung.com,gkobakhi@asu.edu,mhklinux@outlook.com Cc: From: Date: Wed, 02 Dec 2026 14:00:22 +0100 Message-ID: <2026120222-bottom-shortwave-016f@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.12-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.12.y git checkout FETCH_HEAD git cherry-pick -x 5b4b87935bf9c6c81b603558c2e167fc27c22a1b # git commit -s git send-email --to '' --in-reply-to '2026120222-bottom-shortwave-016f@gregkh' --subject-prefix 'PATCH 6.12.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);