History

tracing: Check keys for variable references in expressions too

There's an existing check for variable references in keys, but it doesn't go far enough. It checks whether a key field is a variable reference but doesn't check whether it's an expression containing variable references, which can cause the same problems for callers. Use the existing field_has_hist_vars() function rather than a direct top-level flag check to catch all possible variable references. Link: http://lkml.kernel.org/r/e8c3d3d53db5ca90ceea5a46e5413103a6902fc7.1555597045.git.tom.zanussi@linux.intel.com

Tom Zanussi committed 7 years ago

Commit c8d94a11 parent 55267c81 file · +2 −2Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_events_hist.c+2−2
@@ -59,7 +59,7 @@ · 58 unmodified lines
59 C(NO_CLOSING_PAREN, "No closing paren found"), \59 C(NO_CLOSING_PAREN, "No closing paren found"), \
60 C(SUBSYS_NOT_FOUND, "Missing subsystem"), \60 C(SUBSYS_NOT_FOUND, "Missing subsystem"), \
61 C(INVALID_SUBSYS_EVENT, "Invalid subsystem or event name"), \61 C(INVALID_SUBSYS_EVENT, "Invalid subsystem or event name"), \
62 C(INVALID_REF_KEY, "Using variable references as keys not supported"), \62 C(INVALID_REF_KEY, "Using variable references in keys not supported"), \
63 C(VAR_NOT_FOUND, "Couldn't find variable"), \63 C(VAR_NOT_FOUND, "Couldn't find variable"), \
64 C(FIELD_NOT_FOUND, "Couldn't find field"),64 C(FIELD_NOT_FOUND, "Couldn't find field"),
65 65
@@ -4506,7 +4506,7 @@ static int create_key_field(struct hist_trigger_data *hist_data, · 4440 unmodified lines
4506 goto out;4506 goto out;
4507 }4507 }
4508 4508
4509 if (hist_field->flags & HIST_FIELD_FL_VAR_REF) {4509 if (field_has_hist_vars(hist_field, 0)) {
4510 hist_err(tr, HIST_ERR_INVALID_REF_KEY, errpos(field_str));4510 hist_err(tr, HIST_ERR_INVALID_REF_KEY, errpos(field_str));
4511 destroy_hist_field(hist_field, 0);4511 destroy_hist_field(hist_field, 0);
4512 ret = -EINVAL;4512 ret = -EINVAL;