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]
Message-ID: <201005261425.39058.roman.fietze@telemotive.de>
Date:	Wed, 26 May 2010 14:25:38 +0200
From:	Roman Fietze <roman.fietze@...emotive.de>
To:	Jason Baron <jbaron@...hat.com>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] dynamic_debug: allow to set dynamic debug flags right at module load time

Hello Jason, hello list,

If I'm not wrong one could only enable any dynamic debugging flag
after a module had been completely loaded, using debugfs. This makes
it impossible to use dev_dbg or pr_debug e.g. inside the module init
function or any function called by it.

My patch works by replacing _DPRINTK_FLAGS_DEFAULT after including all
kernel headers in my module source file and some small patch inside
dynamic_debug.c setting up the internal variables already when loading
a module with flags unequal to zero. This patch can of course be
optimized somewhat by reusing existing variables.

Subject: [PATCH] dynamic_debug: allow to set dynamic debug flags right at module load time

This allows to use e.g. pr_debug right from the beginning, e.g. in the
module init function.

- the module must redefine _DPRINTK_FLAGS_DEFAULT, e.g.

  #undef _DPRINTK_FLAGS_DEFAULT
  #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT

- when a module is loaded and the flags are not zero, the enabled
  count and hash masks are enabled right away

Signed-off-by: Roman Fietze <roman.fietze@...emotive.de>
---
 lib/dynamic_debug.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index d6b8b9b..d10466e 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -656,6 +656,8 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 {
 	struct ddebug_table *dt;
 	char *new_name;
+	size_t i;
+	char flagbuf[8];
 
 	dt = kzalloc(sizeof(*dt), GFP_KERNEL);
 	if (dt == NULL)
@@ -671,6 +673,22 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 	dt->ddebugs = tab;
 
 	mutex_lock(&ddebug_lock);
+	for (i = 0 ; i < dt->num_ddebugs ; i++) {
+		struct _ddebug *dp = &dt->ddebugs[i];
+
+		if (dp->flags) {
+			dt->num_enabled++;
+			dynamic_debug_enabled |= (1LL << dp->primary_hash);
+			dynamic_debug_enabled2 |= (1LL << dp->secondary_hash);
+			if (verbose)
+				printk(KERN_INFO
+					"ddebug: added %s:%d [%s]%s %s\n",
+					dp->filename, dp->lineno,
+					dt->mod_name, dp->function,
+					ddebug_describe_flags(dp, flagbuf,
+							sizeof(flagbuf)));
+		}
+	}
 	list_add_tail(&dt->link, &ddebug_tables);
 	mutex_unlock(&ddebug_lock);
 
-- 
1.7.1


-- 
Roman Fietze                Telemotive AG Büro Mühlhausen
Breitwiesen                              73347 Mühlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de
--
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