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: <1384872810-29492-2-git-send-email-alonid@stratoscale.com>
Date:	Tue, 19 Nov 2013 16:53:29 +0200
From:	Dan Aloni <alonid@...atoscale.com>
To:	linux-kernel@...r.kernel.org
Cc:	kvm@...r.kernel.org, kgdb-bugreport@...ts.sourceforge.net,
	x86@...nel.org, gleb@...hat.com, pbonzini@...hat.com,
	tglx@...utronix.de, mingo@...hat.com, hpa@...or.com,
	Muli Ben-Yehuda <muli@...atoscale.com>
Subject: [PATCH linux-next 1/2] kgdb-x86: allow to temporarily disable trap activation

There are some users that would like the ability of a temporary
per-cpu deactivation of the debugger trap.

More specifically, we have seen that when kvm-unit-tests runs with
kgdb enabled, the kernel halts on the debugger during the KVM x86
instruction emulation that performs a test of a division by zero,
and also during fwait.

A second patch depending on this one addresses that issue.

Signed-off-by: Dan Aloni <alonid@...atoscale.com>
Signed-off-by: Muli Ben-Yehuda <muli@...atoscale.com>
---
 arch/x86/include/asm/kgdb.h |  8 ++++++++
 arch/x86/kernel/kgdb.c      | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/arch/x86/include/asm/kgdb.h b/arch/x86/include/asm/kgdb.h
index 332f98c..35bec81 100644
--- a/arch/x86/include/asm/kgdb.h
+++ b/arch/x86/include/asm/kgdb.h
@@ -86,4 +86,12 @@ static inline void arch_kgdb_breakpoint(void)
 extern int kgdb_ll_trap(int cmd, const char *str,
 			struct pt_regs *regs, long err, int trap, int sig);
 
+#ifdef CONFIG_KGDB
+extern void kgdb_ll_local_disable(void);
+extern void kgdb_ll_local_enable(void);
+#else
+#define kgdb_ll_local_disable() do {} while (0)
+#define kgdb_ll_local_enable() do {} while (0)
+#endif
+
 #endif /* _ASM_X86_KGDB_H */
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 836f832..c269ad8 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -587,6 +587,22 @@ int kgdb_ll_trap(int cmd, const char *str,
 	return __kgdb_notify(&args, cmd);
 }
 
+static DEFINE_PER_CPU(bool, kgdb_swallow_traps);
+
+void kgdb_ll_local_disable(void)
+{
+	__this_cpu_write(kgdb_swallow_traps, true);
+}
+
+EXPORT_SYMBOL(kgdb_ll_local_disable);
+
+void kgdb_ll_local_enable(void)
+{
+	__this_cpu_write(kgdb_swallow_traps, false);
+}
+
+EXPORT_SYMBOL(kgdb_ll_local_enable);
+
 static int
 kgdb_notify(struct notifier_block *self, unsigned long cmd, void *ptr)
 {
@@ -594,6 +610,11 @@ kgdb_notify(struct notifier_block *self, unsigned long cmd, void *ptr)
 	int ret;
 
 	local_irq_save(flags);
+	if (__this_cpu_read(kgdb_swallow_traps) && cmd == DIE_TRAP) {
+		local_irq_restore(flags);
+		return NOTIFY_DONE;
+	}
+
 	ret = __kgdb_notify(ptr, cmd);
 	local_irq_restore(flags);
 
-- 
1.8.3.1

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