lists.openwall.net   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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221205145937.54367-11-kbusch@meta.com>
Date:   Mon, 5 Dec 2022 06:59:36 -0800
From:   Keith Busch <kbusch@...a.com>
To:     <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
        Matthew Wilcox <willy@...radead.org>
CC:     Tony Battersby <tonyb@...ernetics.com>,
        Keith Busch <kbusch@...nel.org>
Subject: [PATCH 10/11] dmapool: don't memset on free twice

From: Keith Busch <kbusch@...nel.org>

If debug is enabled, dmapool will poison the range, so no need to clear
it to 0 immediately before writing over it.

Signed-off-by: Keith Busch <kbusch@...nel.org>
---
 mm/dmapool.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index 44622f2bf4641..f5b79c3268856 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -372,10 +372,10 @@ static struct dma_page *pool_find_page(struct dma_pool *pool, dma_addr_t dma)
 	return NULL;
 }
 
+#ifdef DMAPOOL_DEBUG
 static inline bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
 				 void *vaddr)
 {
-#ifdef DMAPOOL_DEBUG
 	unsigned int chain = page->offset;
 
 	if ((dma - page->dma) != offset) {
@@ -394,9 +394,17 @@ static inline bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
 		return true;
 	}
 	memset(vaddr, POOL_POISON_FREED, pool->size);
-#endif
 	return false;
 }
+#else
+static inline bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
+				 void *vaddr)
+{
+	if (want_init_on_free())
+		memset(vaddr, 0, pool->size);
+	return false;
+}
+#endif
 
 /**
  * dma_pool_free - put block back into dma pool
@@ -423,8 +431,6 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
 	}
 
 	offset = vaddr - page->vaddr;
-	if (want_init_on_free())
-		memset(vaddr, 0, pool->size);
 	if (pool_page_err(pool, page, vaddr)) {
 		spin_unlock_irqrestore(&pool->lock, flags);
 		return;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ