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-next>] [day] [month] [year] [list]
Date:	Mon,  5 Nov 2012 14:40:05 +0100
From:	Matthieu CASTET <matthieu.castet@...rot.com>
To:	linux-kernel@...r.kernel.org
Cc:	cl@...ux.com, akpm@...ux-foundation.org,
	Matthieu CASTET <matthieu.castet@...rot.com>
Subject: [PATCH] dmapool : make DMAPOOL_DEBUG detect corruption of free marker

This can help to catch case where hardware is writting after dma free.

Signed-off-by: Matthieu Castet <matthieu.castet@...rot.com>
---
 mm/dmapool.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index c5ab33b..e10898a 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -346,6 +346,29 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
 	retval = offset + page->vaddr;
 	*handle = offset + page->dma;
 #ifdef	DMAPOOL_DEBUG
+	{
+		int i;
+		u8 *data = retval;
+		/* page->offset is stored in first 4 bytes */
+		for (i = sizeof(int); i < pool->size; i++) {
+			if (data[i] != POOL_POISON_FREED) {
+				if (pool->dev)
+					dev_err(pool->dev,
+							"dma_pool_alloc %s, %p (corruped)\n",
+							pool->name, retval);
+				else
+					printk(KERN_ERR
+							"dma_pool_alloc %s, %p (corruped)\n",
+							pool->name, retval);
+
+				/* we dump the first 4 bytes even if there are not
+				   POOL_POISON_FREED */
+				print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1,
+						data, pool->size, 1);
+				break;
+			}
+		}
+	}
 	memset(retval, POOL_POISON_ALLOCATED, pool->size);
 #endif
  done:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ