X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fevent-rule%2Fkprobe.c;h=6846f0cb16a2b664c4635227b09d4b2ee58535b9;hp=a5c93e653f08784dbb4af8997dc1d14c66ba80c9;hb=58daac01d91347336f24e1fc1cacd4e7a3101e93;hpb=077192fd1880652a61400b493a0b6cf5bb199435 diff --git a/src/common/event-rule/kprobe.c b/src/common/event-rule/kprobe.c index a5c93e653..6846f0cb1 100644 --- a/src/common/event-rule/kprobe.c +++ b/src/common/event-rule/kprobe.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -146,7 +147,8 @@ end: } static enum lttng_error_code lttng_event_rule_kprobe_generate_filter_bytecode( - struct lttng_event_rule *rule, uid_t uid, gid_t gid) + struct lttng_event_rule *rule, + const struct lttng_credentials *creds) { /* Nothing to do. */ return LTTNG_OK; @@ -219,19 +221,15 @@ ssize_t lttng_event_rule_kprobe_create_from_payload( goto end; } - if (view->buffer.size < sizeof(*kprobe_comm)) { + current_buffer_view = lttng_buffer_view_from_view( + &view->buffer, offset, sizeof(*kprobe_comm)); + if (!lttng_buffer_view_is_valid(¤t_buffer_view)) { ERR("Failed to initialize from malformed event rule kprobe: buffer too short to contain header."); ret = -1; goto end; } - current_buffer_view = lttng_buffer_view_from_view( - &view->buffer, offset, sizeof(*kprobe_comm)); kprobe_comm = (typeof(kprobe_comm)) current_buffer_view.data; - if (!kprobe_comm) { - ret = -1; - goto end; - } rule = lttng_event_rule_kprobe_create(); if (!rule) { @@ -251,12 +249,12 @@ ssize_t lttng_event_rule_kprobe_create_from_payload( lttng_payload_view_from_view(view, offset, kprobe_comm->name_len); - name = current_payload_view.buffer.data; - if (!name) { + if (!lttng_payload_view_is_valid(¤t_payload_view)) { ret = -1; goto end; } + name = current_payload_view.buffer.data; if (!lttng_buffer_view_contains_string( ¤t_payload_view.buffer, name, kprobe_comm->name_len)) { @@ -274,6 +272,11 @@ ssize_t lttng_event_rule_kprobe_create_from_payload( lttng_payload_view_from_view(view, offset, kprobe_comm->location_len); + if (!lttng_payload_view_is_valid(¤t_payload_view)) { + ret = -1; + goto end; + } + ret = lttng_kernel_probe_location_create_from_payload( ¤t_payload_view, &location); if (ret < 0) {