From: Mathieu Desnoyers Date: Fri, 22 Sep 2017 20:00:29 +0000 (-0400) Subject: Filter: catch shift undefined behavior X-Git-Tag: v2.11.0-rc1~10 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3703f1d2e6e5a48c5fe066a7df0d1cc7f76ea4f0;p=lttng-ust.git Filter: catch shift undefined behavior Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-filter-interpreter.c b/liblttng-ust/lttng-filter-interpreter.c index 1e7b12a5..1354d9c1 100644 --- a/liblttng-ust/lttng-filter-interpreter.c +++ b/liblttng-ust/lttng-filter-interpreter.c @@ -1557,7 +1557,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, ret = -EINVAL; goto end; } - + /* Catch undefined behavior. */ + if (caa_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, ax_t, bx_t); estack_ax_v = res; @@ -1574,7 +1578,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, ret = -EINVAL; goto end; } - + /* Catch undefined behavior. */ + if (caa_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, ax_t, bx_t); estack_ax_v = res;