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:	Thu, 19 Apr 2012 11:12:53 -0700
From:	Roland Dreier <roland@...nel.org>
To:	Joerg Roedel <joerg.roedel@....com>,
	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] dma-debug: Fix deadlock with netconsole or other drivers that use the DMA API

From: Roland Dreier <roland@...estorage.com>

If we exhaust the free_entries list, then we print the error message

    DMA-API: debugging out of memory - disabling

to the kernel log, while holding free_entries_lock.  Unfortunately, if
the console driver ends up calling back into the DMA API to map a
buffer, as eg a NIC driver is quite likely to for the packet netconsole
asks it to send, this will deadlock on free_entries_lock.

A fix is pretty simple: if we flip the order of setting global_disable
to be before we print the error message, then the nested call into the
DMA API will bail out before trying to get free_entries_lock.

Signed-off-by: Roland Dreier <roland@...estorage.com>
---
 lib/dma-debug.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 13ef233..f198b4e 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -436,8 +436,8 @@ static struct dma_debug_entry *dma_entry_alloc(void)
 	spin_lock_irqsave(&free_entries_lock, flags);
 
 	if (list_empty(&free_entries)) {
-		pr_err("DMA-API: debugging out of memory - disabling\n");
 		global_disable = true;
+		pr_err("DMA-API: debugging out of memory - disabling\n");
 		goto out;
 	}
 
-- 
1.7.9.5

--
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