From: Masami Hiramatsu (Google) <[email protected]> In parse_pred(), by the time the '.function' field size and operator checks are reached, 'i' has already been advanced past the operator to the operand.
Save the position of the '.function' modifier in 'fn_pos' and pass 'pos + fn_pos' for ILLEGAL_FIELD_OP and 'pos + op_pos' for INVALID_OP so the error caret points to '.function' and the operator respectively. Signed-off-by: Masami Hiramatsu (Google) <[email protected]> --- Changes in v4: - Drop Fixes and Cc: stable tags since this error position fix is a cleanup. Changes in v3: - Newly added to fix error positions for .function modifier and operator checks in parse_pred(). --- kernel/trace/trace_events_filter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 6ff208f0e033..9b1100769676 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1701,6 +1701,7 @@ static int parse_pred(const char *str, void *data, int op; int s; int field_pos = 0; + int fn_pos = 0; int op_pos = 0; int i = 0; @@ -1742,6 +1743,7 @@ static int parse_pred(const char *str, void *data, /* See if the field is a kernel function name */ if ((len = str_has_prefix(str + i, ".function"))) { function = true; + fn_pos = i; i += len; } @@ -1785,7 +1787,7 @@ static int parse_pred(const char *str, void *data, if (function) { /* The field must be the same size as long */ if (field->size != sizeof(long)) { - parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + fn_pos); goto err_free; } @@ -1795,7 +1797,7 @@ static int parse_pred(const char *str, void *data, case OP_EQ: break; default: - parse_error(pe, FILT_ERR_INVALID_OP, pos + i); + parse_error(pe, FILT_ERR_INVALID_OP, pos + op_pos); goto err_free; }
