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: <1329717879.3448.30.camel@ThinkPad-T61>
Date:	Mon, 20 Feb 2012 14:04:39 +0800
From:	Li Zhong <zhong@...ux.vnet.ibm.com>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	tglx@...utronix.de, mingo@...hat.com, hpa@...or.com,
	x86@...nel.org, a.p.zijlstra@...llo.nl, paulus@...ba.org,
	mingo@...e.hu, acme@...stprotocols.net
Subject: [PATCH 1/2 x86] fix page faults by nmi handler in nmi if kmemcheck
 is enabled

This patch tries to
  change the nmi handler name from a pointer to an array. 
  use __get_free_pages instead of kzalloc if CONFIG_KMEMCHECK is
enabled.

Signed-off-by: Li Zhong <zhong@...ux.vnet.ibm.com>
---
 arch/x86/kernel/nmi.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 47acaf3..84aa03a 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -36,7 +36,7 @@ struct nmiaction {
 	struct list_head list;
 	nmi_handler_t handler;
 	unsigned int flags;
-	char *name;
+	char name[NMI_MAX_NAMELEN];
 };
 
 struct nmi_desc {
@@ -169,16 +169,18 @@ int register_nmi_handler(unsigned int type,
nmi_handler_t handler,
 	if (!handler)
 		return -EINVAL;
 
+#ifdef CONFIG_KMEMCHECK
+	action = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+				get_order(sizeof(*action)));
+#else
 	action = kzalloc(sizeof(struct nmiaction), GFP_KERNEL);
+#endif
 	if (!action)
 		goto fail_action;
 
 	action->handler = handler;
 	action->flags = nmiflags;
-	action->name = kstrndup(devname, NMI_MAX_NAMELEN, GFP_KERNEL);
-	if (!action->name)
-		goto fail_action_name;
-
+	strncpy(action->name, devname, sizeof(action->name));
 	retval = __setup_nmi(type, action);
 
 	if (retval)
@@ -187,9 +189,11 @@ int register_nmi_handler(unsigned int type,
nmi_handler_t handler,
 	return retval;
 
 fail_setup_nmi:
-	kfree(action->name);
-fail_action_name:
+#ifdef CONFIG_KMEMCHECK
+	free_pages((unsigned long)action, get_order(sizeof(*action)));
+#else
 	kfree(action);
+#endif
 fail_action:	
 
 	return retval;
@@ -202,8 +206,11 @@ void unregister_nmi_handler(unsigned int type,
const char *name)
 
 	a = __free_nmi(type, name);
 	if (a) {
-		kfree(a->name);
+#ifdef CONFIG_KMEMCHECK
+		free_pages((unsigned long)a, get_order(sizeof(*a)));
+#else
 		kfree(a);
+#endif
 	}
 }
 
-- 
1.7.5.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