From: Christian Babeux Date: Sat, 29 Sep 2012 17:37:40 +0000 (-0400) Subject: Fix: reloc offset validation error out on filters with no reloc table X-Git-Tag: v2.1.0-rc2~34 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=885b1dfd5d050ed5610721d9ec840bfd121644ec Fix: reloc offset validation error out on filters with no reloc table 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 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 Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index a464e88b..efc6724f 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -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;