* FAILED: patch "[PATCH] tracing: Reject string operand in the histogram expression" failed to apply to 4.19-stable tree
@ 2021-08-09 9:14 gregkh
2021-08-11 7:39 ` [PATCH 4.19.y] tracing: Reject string operand in the histogram expression Masami Hiramatsu
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2021-08-09 9:14 UTC (permalink / raw)
To: mhiramat, rostedt; +Cc: stable
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a9d10ca4986571bffc19778742d508cc8dd13e02 Mon Sep 17 00:00:00 2001
From: Masami Hiramatsu <mhiramat@kernel.org>
Date: Wed, 28 Jul 2021 07:55:43 +0900
Subject: [PATCH] tracing: Reject string operand in the histogram expression
Since the string type can not be the target of the addition / subtraction
operation, it must be rejected. Without this fix, the string type silently
converted to digits.
Link: https://lkml.kernel.org/r/162742654278.290973.1523000673366456634.stgit@devnote2
Cc: stable@vger.kernel.org
Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 362db9b81b8d..949ef09dc537 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -65,7 +65,8 @@
C(INVALID_SORT_MODIFIER,"Invalid sort modifier"), \
C(EMPTY_SORT_FIELD, "Empty sort field"), \
C(TOO_MANY_SORT_FIELDS, "Too many sort fields (Max = 2)"), \
- C(INVALID_SORT_FIELD, "Sort field must be a key or a val"),
+ C(INVALID_SORT_FIELD, "Sort field must be a key or a val"), \
+ C(INVALID_STR_OPERAND, "String type can not be an operand in expression"),
#undef C
#define C(a, b) HIST_ERR_##a
@@ -2156,6 +2157,13 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
ret = PTR_ERR(operand1);
goto free;
}
+ if (operand1->flags & HIST_FIELD_FL_STRING) {
+ /* String type can not be the operand of unary operator. */
+ hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(str));
+ destroy_hist_field(operand1, 0);
+ ret = -EINVAL;
+ goto free;
+ }
expr->flags |= operand1->flags &
(HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS);
@@ -2257,6 +2265,11 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
operand1 = NULL;
goto free;
}
+ if (operand1->flags & HIST_FIELD_FL_STRING) {
+ hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(operand1_str));
+ ret = -EINVAL;
+ goto free;
+ }
/* rest of string could be another expression e.g. b+c in a+b+c */
operand_flags = 0;
@@ -2266,6 +2279,11 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
operand2 = NULL;
goto free;
}
+ if (operand2->flags & HIST_FIELD_FL_STRING) {
+ hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(str));
+ ret = -EINVAL;
+ goto free;
+ }
ret = check_expr_operands(file->tr, operand1, operand2);
if (ret)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 4.19.y] tracing: Reject string operand in the histogram expression
2021-08-09 9:14 FAILED: patch "[PATCH] tracing: Reject string operand in the histogram expression" failed to apply to 4.19-stable tree gregkh
@ 2021-08-11 7:39 ` Masami Hiramatsu
2021-08-13 8:37 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2021-08-11 7:39 UTC (permalink / raw)
To: stable; +Cc: mhiramat, rostedt
commit a9d10ca4986571bffc19778742d508cc8dd13e02 upstream
Since the string type can not be the target of the addition / subtraction
operation, it must be rejected. Without this fix, the string type silently
converted to digits.
Link: https://lkml.kernel.org/r/162742654278.290973.1523000673366456634.stgit@devnote2
Cc: stable@vger.kernel.org
Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
- Since there is no hist_err() APIs in 4.19, this just check the flag
and return an error without any error messages.
---
kernel/trace/trace_events_hist.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 28e4ff45cb4c..e9106c976a48 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -2781,6 +2781,12 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
ret = PTR_ERR(operand1);
goto free;
}
+ if (operand1->flags & HIST_FIELD_FL_STRING) {
+ /* String type can not be the operand of unary operator. */
+ destroy_hist_field(operand1, 0);
+ ret = -EINVAL;
+ goto free;
+ }
expr->flags |= operand1->flags &
(HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS);
@@ -2881,6 +2887,10 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
operand1 = NULL;
goto free;
}
+ if (operand1->flags & HIST_FIELD_FL_STRING) {
+ ret = -EINVAL;
+ goto free;
+ }
/* rest of string could be another expression e.g. b+c in a+b+c */
operand_flags = 0;
@@ -2890,6 +2900,10 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
operand2 = NULL;
goto free;
}
+ if (operand2->flags & HIST_FIELD_FL_STRING) {
+ ret = -EINVAL;
+ goto free;
+ }
ret = check_expr_operands(operand1, operand2);
if (ret)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.19.y] tracing: Reject string operand in the histogram expression
2021-08-11 7:39 ` [PATCH 4.19.y] tracing: Reject string operand in the histogram expression Masami Hiramatsu
@ 2021-08-13 8:37 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2021-08-13 8:37 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: stable, rostedt
On Wed, Aug 11, 2021 at 04:39:46PM +0900, Masami Hiramatsu wrote:
> commit a9d10ca4986571bffc19778742d508cc8dd13e02 upstream
>
> Since the string type can not be the target of the addition / subtraction
> operation, it must be rejected. Without this fix, the string type silently
> converted to digits.
>
> Link: https://lkml.kernel.org/r/162742654278.290973.1523000673366456634.stgit@devnote2
>
> Cc: stable@vger.kernel.org
> Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers")
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> - Since there is no hist_err() APIs in 4.19, this just check the flag
> and return an error without any error messages.
> ---
> kernel/trace/trace_events_hist.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
Both backports applied, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-13 8:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 9:14 FAILED: patch "[PATCH] tracing: Reject string operand in the histogram expression" failed to apply to 4.19-stable tree gregkh
2021-08-11 7:39 ` [PATCH 4.19.y] tracing: Reject string operand in the histogram expression Masami Hiramatsu
2021-08-13 8:37 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.