Fix: reloc offset validation error out on filters with no reloc table
authorChristian Babeux <christian.babeux@efficios.com>
Sat, 29 Sep 2012 17:37:40 +0000 (13:37 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 29 Sep 2012 17:37:40 +0000 (13:37 -0400)
The reloc table is currently appended at the end of the bytecode data.
With this scheme, the reloc table offset will be equal to the length
of the bytecode data.

<- length ->
+----------+-------------+
| BYTECODE | RELOC TABLE |
+----------+-------------+
           |
           +--> Reloc table offset

A special case arise with filters with no reloc table.

Example:

Filter: "myString" == "yourString"
./filter-grammar-test -p -B -i -b < bogus
<root>
        <op type="==">
                <expression>
                        <string value="myString"/>
                </expression>
                <expression>
                        <string value="yourString"/>
                </expression>
        </op>
</root>
Generating IR... done
Validating IR... done
Generating bytecode... done
Size of bytecode generated: 24 bytes.
Bytecode:

Val. Operator
---- --------
0x40 (FILTER_OP_LOAD_STRING)
0x6D m
0x79 y
0x53 S
0x74 t
0x72 r
0x69 i
0x6E n
0x67 g
0x00 \0
0x40 (FILTER_OP_LOAD_STRING)
0x79 y
0x6F o
0x75 u
0x72 r
0x53 S
0x74 t
0x72 r
0x69 i
0x6E n
0x67 g
0x00 \0
0x0C (FILTER_OP_EQ)
0x01 (FILTER_OP_RETURN)

Reloc table (offset: 24):
Empty

<-   24   ->
+----------+
| BYTECODE | <- No reloc table
+----------+
           |
           +--> Reloc table offset

In this case, we see that the reloc table offset (24) is indeed equal to
the length of the bytecode (24), but the reloc table is _empty_. Thus,
the reloc_offset received in handle_message() will be equal to the
data_size and will be wrongly flagged as not within the data even thought
the filter is entirely valid.

The fix is to simply allow a reloc_offset to be equal to the data_size.

Fixes #342

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-ust-comm.c

index a464e88bfee2143e429273c646adabbf8aaa61bb..efc6724f1b6510538e3a2d7063c1dc8093e02c6c 100644 (file)
@@ -294,7 +294,7 @@ int handle_message(struct sock_info *sock_info,
                        goto error;
                }
 
-               if (lum->u.filter.reloc_offset > lum->u.filter.data_size - 1) {
+               if (lum->u.filter.reloc_offset > lum->u.filter.data_size) {
                        ERR("Filter reloc offset %u is not within data\n",
                                lum->u.filter.reloc_offset);
                        ret = -EINVAL;
This page took 0.026321 seconds and 4 git commands to generate.