From: Mathieu Desnoyers Date: Fri, 22 Sep 2017 20:00:13 +0000 (-0400) Subject: Filter: catch shift undefined behavior X-Git-Tag: v2.11.0-rc1~47 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ea13ec960f55bac1d08e5ec3523797ccdbde573b;p=lttng-modules.git Filter: catch shift undefined behavior Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c index 5bf0bd60..b1e5ba73 100644 --- a/lttng-filter-interpreter.c +++ b/lttng-filter-interpreter.c @@ -990,6 +990,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { int64_t res; + /* Catch undefined behavior. */ + if (unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) { + ret = -EINVAL; + goto end; + } res = (estack_bx_v >> estack_ax_v); estack_pop(stack, top, ax, bx); estack_ax_v = res; @@ -1000,6 +1005,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { int64_t res; + /* Catch undefined behavior. */ + if (unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) { + ret = -EINVAL; + goto end; + } res = (estack_bx_v << estack_ax_v); estack_pop(stack, top, ax, bx); estack_ax_v = res;