Filter: catch shift undefined behavior
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Sep 2017 20:00:29 +0000 (16:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Jun 2018 20:40:15 +0000 (16:40 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-filter-interpreter.c

index 1e7b12a5da4e0243ed1e00deb9b359b0569bb789..1354d9c1062e5bebf1d764cf31e9116f32124116 100644 (file)
@@ -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;
This page took 0.025322 seconds and 4 git commands to generate.