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]
Date:   Tue,  3 Aug 2021 00:23:45 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     linux-trace-devel@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, Tom Zanussi <zanussi@...nel.org>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-rt-users <linux-rt-users@...r.kernel.org>,
        Clark Williams <williams@...hat.com>,
        "Steven Rostedt (VMware)" <rostedt@...dmis.org>
Subject: [PATCH v2 19/21] libtracefs: Allow trace_sql() to take keywords for fields with backslash

From: "Steven Rostedt (VMware)" <rostedt@...dmis.org>

Some events have fields with keywords, and the parsing will not let it
work. For example, you can have:

  select from from regcache_drop_region

And that will produce a syntax error, as the from will confuse the parser.
Allow fields to start with a backslash, which will allow the parser to see
"from" as a field and not as a keyword. That is:

  select \from from regcache_drop_region

will work as expected. Note, any field can start with a backslash, and the
starting backslash will be ignored.

Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
 Documentation/libtracefs-sql.txt | 20 ++++++++++++++++++++
 src/sqlhist.l                    |  6 ++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/Documentation/libtracefs-sql.txt b/Documentation/libtracefs-sql.txt
index 190abe641d7c..e38ed7649432 100644
--- a/Documentation/libtracefs-sql.txt
+++ b/Documentation/libtracefs-sql.txt
@@ -162,6 +162,26 @@ select start.pid, (end.TIMESTAMP_USECS - start.TIMESTAMP_USECS) as lat from sche
    WHERE start.prio < 100 || end.prev_prio < 100
 --
 
+
+KEYWORDS AS EVENT FIELDS
+------------------------
+
+In some cases, an event may have a keyword. For example, regcache_drop_region has "from"
+as a field and the following will not work
+
+[source,c]
+--
+  select from from regcache_drop_region
+--
+
+In such cases, add a backslash to the conflicting field, and this will tell the parser
+that the "from" is a field and not a keyword:
+
+[source,c]
+--
+  select \from from regcache_drop_region
+--
+
 HISTOGRAMS
 ----------
 
diff --git a/src/sqlhist.l b/src/sqlhist.l
index f9e0fcc17e63..897daac7d2a8 100644
--- a/src/sqlhist.l
+++ b/src/sqlhist.l
@@ -25,7 +25,7 @@ extern int my_yyinput(void *extra, char *buf, int max);
 %option reentrant
 %option bison-bridge
 
-field		[a-z_][a-z0-9_\.]*
+field		\\?[a-z_][a-z0-9_\.]*
 qstring		\"[^\"]*\"
 hexnum		0x[0-9a-f]+
 number		[0-9a-f]+
@@ -46,8 +46,10 @@ where { HANDLE_COLUMN; return WHERE; }
 }
 
 {field} {
+	const char *str = yyg->yytext_r;
 	HANDLE_COLUMN;
-	yylval->string = store_str(TRACE_SB, yyg->yytext_r);
+	if (str[0] == '\\') { str++; };
+	yylval->string = store_str(TRACE_SB, str);
 	return FIELD;
 }
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ