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: <20200620180643.887546-17-jim.cromie@gmail.com>
Date:   Sat, 20 Jun 2020 12:06:42 -0600
From:   Jim Cromie <jim.cromie@...il.com>
To:     jbaron@...mai.com, linux-kernel@...r.kernel.org,
        akpm@...uxfoundation.org, gregkh@...uxfoundation.org
Cc:     linux@...musvillemoes.dk, Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH v4 16/17] dyndbg: allow anchored match on format query term

This should work:

  echo module=amd* format=^[IF_TRACE]: +p  >/proc/dynamic_debug/control

consider drivers/gpu/drm/amd/display/include/logger_types.h:
It has 11 defines like:

  #define DC_LOG_IF_TRACE(...) pr_debug("[IF_TRACE]:"__VA_ARGS__)

These defines are used 804 times at recent count; they are a perfect
test case to leverage existing format-message based classifications of
*pr_debug*.

Those macros prefix the supplied message with a fixed string, Id
expect nearly all existing classification schemes to do so.  Hence we
want to be able to anchor our match to the beginning of the format
string, so ddebug_exec_queries() can be more exact.  This gives easier
contruction of reliable queries to enable/disable those callsites.

This makes no attempt at wider regex features, just the one we need.

Since this is a corner-case of sorts, lets examine one more, hidden in
the example above; note the "module=amd*" query term.

  // normal usage
  ddebug_exec_queries("format=^[IF_TRACE]: +p", MODULE)
  // wildcard 1
  ddebug_exec_queries("module=amd* format=^[IF_TRACE]: +p", NULL)
  // wildcard 2
  ddebug_exec_queries("format=^[IF_TRACE]: +p", "amd*")

Now, I doubt that "amd*" is useful here, but I dont see a reason
to preclude it; multiple modules with coordinated classifcation
schemes is reasonable.  That said, a single call can have multiple
queries, each with an exact module name.

I also see little reason to prefer either of forms 1 or 2.  Its
case-by-case, judging brevity, clarity, and query specificity and
robustness.

Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
 lib/dynamic_debug.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index b00f536d6d12..d737c733967a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -176,9 +176,15 @@ static int ddebug_change(const struct ddebug_query *query,
 				continue;
 
 			/* match against the format */
-			if (query->format &&
-			    !strstr(dp->format, query->format))
-				continue;
+			if (query->format) {
+				if (*query->format == '^') {
+					/* anchored search. match must be at beginning */
+					char *p = strstr(dp->format, query->format+1);
+					if (p != dp->format)
+						continue;
+				} else if (!strstr(dp->format, query->format))
+					continue;
+			}
 
 			/* match against the line number range */
 			if (query->first_lineno &&
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ