lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 25 Oct 2023 10:44:25 +0200
From:   Petr Tesarik <>
To:     Christoph Hellwig <>,
        Marek Szyprowski <>,
        Robin Murphy <>,
        Petr Tesarik <>, (open list:DMA MAPPING HELPERS), (open list)
Cc:     Wangkefeng <>,
        Roberto Sassu <>,, Ben Greear <>
Subject: [PATCH] swiotlb: Do not try to allocate a TLB bigger than MAX_ORDER pages

From: Petr Tesarik <>

When allocating a new pool at runtime, reduce the number of slabs so that
the allocation order is at most MAX_ORDER. This avoids a kernel WARNING in

The warning is relatively benign, because the pool size is subsequently
reduced when allocation fails, but it is silly to start with a request that
is known to fail, especially since this is the default behavior if the
kernel is built with CONFIG_SWIOTLB_DYNAMIC=y and booted without any
swiotlb= parameter.

Reported-by: Ben Greear <>
Fixes: 1aaa736815eb ("swiotlb: allocate a new memory pool when existing pools are full")
Signed-off-by: Petr Tesarik <>
 kernel/dma/swiotlb.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 01637677736f..dff067bd56b1 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -678,6 +678,11 @@ static struct io_tlb_pool *swiotlb_alloc_pool(struct device *dev,
 	size_t pool_size;
 	size_t tlb_size;
+	if (nslabs > SLABS_PER_PAGE << MAX_ORDER) {
+		nslabs = SLABS_PER_PAGE << MAX_ORDER;
+		nareas = limit_nareas(nareas, nslabs);
+	}
 	pool_size = sizeof(*pool) + array_size(sizeof(*pool->areas), nareas);
 	pool = kzalloc(pool_size, gfp);
 	if (!pool)

Powered by blists - more mailing lists