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=1796221022; b=Km7nsjHo1t9Q8hJ0G1ePnNkx+mV3mDuIhM61TNg71qczqUzo0mr+CeURV+Z8Kpixrpuo UF9bQFC1C+1qyrR/5VlyivMeAA5CwslOXf5XYLhaBXhEUe7TCbzZ2Yqg9f3UKHZLtqOxg hVn0iHztE3EqAi31muWzGY9SbbPqs7rA6ht/eec9QdtlNphXhqeDTNEN69f0P2yjy0ua9 ht5Y0dPOVA1nZGX/AHe9xLPZvbMimYHs7z3GHihdyCGjpTE2DDhxligjk6qOSuHBh3ZyT 2ws1SzOdPl94w9Up3pD/BI7Hfzd0fLXrpiZoJF6Nf5Eeg0HdgMHB72hQ/0oFBWeIvyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221022; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=7vlsrR0Vsti3uGUDHtVUOdxsO9QPz5UIxGMjdMtY+bI=; b=cMg7bgKCZ1ISMxrAS2U+2t2hZ/EsU7qRvYqf74xO0Xk2DxP/dTxfxDSgNYTFyzi0JnRz 6pK7o4rDHdq4XG24KtlUW519wAP5emD/RbkPsjOVX9uSJkmIzDNBwjzLva+6BbENccrmA pKTcFmnQvO3s/lLyb2ARs+P9whLp9mqOG6MJ7awB8gsSKO/JG6P85zgUZVLqXo1piX8E2 XuvnXu3xShLisG3QMM5IaPPv0cRpLy7A2FEW3xJC1AYGlMc95zcIrVPJsWpOjRSVcPjyC 9ht4dCh+FBqMw5aI3u3VznSSnh2oeI+MNk2iJoyGkBKn0uhDVaC3RzrUwm4LYNujP9A== 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=aLRs7aKa; 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 9055360A263A for ; Wed, 2 Dec 2026 14:17:02 +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=aLRs7aKa Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD0211F008A0; Wed, 2 Dec 2026 14:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221022; bh=7vlsrR0Vsti3uGUDHtVUOdxsO9QPz5UIxGMjdMtY+bI=; h=Subject:To:Cc:From:Date; b=aLRs7aKaccNJXOL15tdOkbCcBSNbe21s3sRpZJVSFg1qZekz8F211UND4TqXIhWoe Tvf4483qJbw6yTAgaKcUYCEdbGkJm0eimrkv1hMftJk13BZWid2aPHts2ivCmtKE2R GaE9+hiUxIOsMkFnuf7/GYTn6RPeJUDHkD/jhaBY= Subject: FAILED: patch "[PATCH] dma: swiotlb: Round restricted DMA pool size down to" failed to apply to 6.6-stable tree To: m.szyprowski@samsung.com,gkobakhi@asu.edu,mhklinux@outlook.com Cc: From: Date: Wed, 02 Dec 2026 14:00:23 +0100 Message-ID: <2026120223-underline-scoff-4a47@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.6-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.6.y git checkout FETCH_HEAD git cherry-pick -x 5b4b87935bf9c6c81b603558c2e167fc27c22a1b # git commit -s git send-email --to '' --in-reply-to '2026120223-underline-scoff-4a47@gregkh' --subject-prefix 'PATCH 6.6.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);