Fix: bytecode validator: reject specialized load instructions
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Sep 2022 20:45:26 +0000 (16:45 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Sep 2022 21:01:54 +0000 (17:01 -0400)
Reject specialized load instructions so a bytecode crafted with
nefarious intent cannot:

- Read user-space memory without proper get_user accessors,
- Read a memory area larger than the memory targeted by the instrumentation.

This prevents bytecode received from a tracing group user from oopsing
the kernel or disclosing the content of kernel memory to the tracing
group.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia70bb2da645d6a0b36515a8ac51995c13283d4cc

lttng-filter-validator.c

index c479af08153c1d152793f2a4a9260ac7b11b21ed..2a5db1198215aabfc1d4e39f77cfc26e0f1b49cf 100644 (file)
@@ -976,60 +976,30 @@ int validate_instruction_context(struct bytecode_runtime *bytecode,
                dbg_printk("Validate load field\n");
                break;
        }
+
+       /*
+        * Disallow already specialized bytecode op load field instructions to
+        * ensure that the received bytecode does not:
+        *
+        * - Read user-space memory without proper get_user accessors,
+        * - Read a memory area larger than the memory targeted by the instrumentation.
+        */
        case FILTER_OP_LOAD_FIELD_S8:
-       {
-               dbg_printk("Validate load field s8\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_S16:
-       {
-               dbg_printk("Validate load field s16\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_S32:
-       {
-               dbg_printk("Validate load field s32\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_S64:
-       {
-               dbg_printk("Validate load field s64\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_U8:
-       {
-               dbg_printk("Validate load field u8\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_U16:
-       {
-               dbg_printk("Validate load field u16\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_U32:
-       {
-               dbg_printk("Validate load field u32\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_U64:
-       {
-               dbg_printk("Validate load field u64\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_STRING:
-       {
-               dbg_printk("Validate load field string\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_SEQUENCE:
-       {
-               dbg_printk("Validate load field sequence\n");
-               break;
-       }
        case FILTER_OP_LOAD_FIELD_DOUBLE:
        {
-               dbg_printk("Validate load field double\n");
-               break;
+               dbg_printk("Validate load field, reject specialized load instruction (%d)\n",
+                               (int) opcode);
+               ret = -EINVAL;
+               goto end;
        }
 
        case FILTER_OP_GET_SYMBOL:
This page took 0.027314 seconds and 4 git commands to generate.