summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2020-12-11 07:27:55 +0000
committeranton <anton@openbsd.org>2020-12-11 07:27:55 +0000
commit85e665dc337dc8951ed1d2e14417b82acd4995e5 (patch)
tree447388306ed67f473f595048c87d6bc96a33c807
parentpass down the `skip' flag to the mountfs() function in the case of (diff)
downloadwireguard-openbsd-85e665dc337dc8951ed1d2e14417b82acd4995e5.tar.xz
wireguard-openbsd-85e665dc337dc8951ed1d2e14417b82acd4995e5.zip
Tracing syscalls which conflict with reserved bt(5) keywords currently
causes btrace to reject such programs. An example is exit which is both a syscall and a builtin btrace function. Pointed out by bluhm@ To resolve the conflict, make use of a lexer backdoor. A concept described in the original yacc paper and also found in other yacc parsers in our tree. ok bluhm@ mpi@
-rw-r--r--usr.sbin/btrace/bt_parse.y19
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y
index ee4ac9b259d..520b544040f 100644
--- a/usr.sbin/btrace/bt_parse.y
+++ b/usr.sbin/btrace/bt_parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_parse.y,v 1.19 2020/12/07 20:14:35 anton Exp $ */
+/* $OpenBSD: bt_parse.y,v 1.20 2020/12/11 07:27:55 anton Exp $ */
/*
* Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org>
@@ -98,6 +98,8 @@ typedef struct {
static void yyerror(const char *, ...);
static int yylex(void);
+
+static int pflag;
%}
%token ERROR OP_EQ OP_NEQ BEGIN END HZ
@@ -112,7 +114,7 @@ static int yylex(void);
%type <v.i> filterval oper builtin
%type <v.i> BUILTIN F_DELETE F_PRINT FUNC0 FUNC1 FUNCN OP1 OP4
%type <v.i> MOP0 MOP1
-%type <v.probe> probe
+%type <v.probe> probe probeval
%type <v.filter> predicate
%type <v.stmt> action stmt stmtlist
%type <v.arg> expr vargs map mexpr printargs term
@@ -138,7 +140,9 @@ beginend : BEGIN { $$ = B_RT_BEGIN; }
| END { $$ = B_RT_END; }
;
-probe : STRING ':' STRING ':' STRING { $$ = bp_new($1, $3, $5, 0); }
+probe : { pflag = 1; } probeval { $$ = $2; pflag = 0; }
+
+probeval : STRING ':' STRING ':' STRING { $$ = bp_new($1, $3, $5, 0); }
| STRING ':' HZ ':' NUMBER { $$ = bp_new($1, "hz", NULL, $5); }
;
@@ -784,6 +788,15 @@ again:
err(1, "%s", __func__);
return STRING;
}
+ if (pflag) {
+ /*
+ * Probe lexer backdoor, interpret the token as a string
+ * rather than a keyword. Otherwise, reserved keywords
+ * would conflict with syscall names.
+ */
+ yylval.v.string = kwp->word;
+ return STRING;
+ }
yylval.v.i = kwp->type;
return kwp->token;
}