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: <1309244992-2305-11-git-send-email-jim.cromie@gmail.com>
Date:	Tue, 28 Jun 2011 01:09:51 -0600
From:	Jim Cromie <jim.cromie@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	gnb@...h.org, jbaron@...hat.com, bvanassche@....org,
	gregkh@...e.de, Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 10/11] dynamic_debug: call apply_pending_queries from ddebug_add_module

When a module is loaded, ddebug_add_module calls apply_pending_queries
to scan pending_queries list and call ddebug_change to apply them.
Matching rules are removed from pending_queries.

With this change, the loaded module's pr_debugs are enabled when
its module_init is invoked, which is not possible otherwize.

With verbose=1, kernel logs look like:

apply_pending_queries: check: pc8736x_gpio <-> q->function="(null)" q->filename="(null)" q->module="pc8736x_gpio" q->format="(null)" q->lineno=0-0 q->flags=0x1 q->mask=0xffffffff

ddebug_change: changed /home/jimc/projects/lx/linux-2.6/drivers/char/pc8736x_gpio.c:342 [pc8736x_gpio]pc8736x_gpio_cleanup p
ddebug_change: changed /home/jimc/projects/lx/linux-2.6/drivers/char/pc8736x_gpio.c:319 [pc8736x_gpio]pc8736x_gpio_init p
...
platform pc8736x_gpio.0: NatSemi pc8736x GPIO Driver Initializing
platform pc8736x_gpio.0: GPIO ioport 6600 reserved

Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
 lib/dynamic_debug.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 37d0275..252888a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -126,8 +126,8 @@ static char *show_ddebug_query(const struct ddebug_query *q)
 }
 
 /* copy query off stack, save flags & mask, and store in pending-list */
-static void add_to_pending(const struct ddebug_query *query,
-			   unsigned int flags, unsigned int mask)
+static void ddebug_add_to_pending(struct ddebug_query *query,
+				unsigned int flags, unsigned int mask)
 {
 	struct pending_query *pq;
 
@@ -351,6 +351,20 @@ static char *unescape(char *str)
 	return str;
 }
 
+static char *show_pending_query(struct pending_query *pq)
+{
+	struct ddebug_query *dq = &pq->query;
+        sprintf(prbuf_query,
+		"q->function=\"%s\" q->filename=\"%s\" "
+		"q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u "
+		"q->flags=0x%x q->mask=0x%x\n",
+		dq->function, dq->filename, dq->module, dq->format,
+		dq->first_lineno, dq->last_lineno,
+		pq->flags, pq->mask);
+
+	return prbuf_query;
+}
+
 static inline void check_set(const char **dest, char *src, char *name)
 {
 	if (*dest)
@@ -786,6 +800,35 @@ static const struct file_operations ddebug_proc_fops = {
 	.write = ddebug_proc_write
 };
 
+/* apply matching queries in pending-queries list */
+static void apply_pending_queries(struct ddebug_table *dt)
+{
+	struct pending_query *pq, *pqnext;
+	int nfound;
+
+	if (verbose)
+		pr_info("pending_ct: %d\n", pending_ct);
+
+	list_for_each_entry_safe(pq, pqnext, &pending_queries, link) {
+		
+		if (verbose)
+			pr_info("check: %s <-> %s\n",
+				dt->mod_name, show_pending_query(pq));
+
+		nfound = ddebug_change(&pq->query, pq->flags, pq->mask);
+
+		if (nfound) {
+			mutex_lock(&ddebug_lock);
+			list_del(&pq->link);
+			mutex_unlock(&ddebug_lock);
+			kfree(pq);
+			pending_ct--;
+		}
+		else if (verbose)
+			pr_info("no-match: %s\n", show_pending_query(pq));
+	}
+
+}
 /*
  * Allocate a new ddebug_table for the given module
  * and add it to the global list.
@@ -815,6 +858,9 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 
 	if (verbose)
 		pr_info("%u debug prints in module %s\n", n, dt->mod_name);
+
+	apply_pending_queries(dt);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ddebug_add_module);
-- 
1.7.4.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