Fix: Filter ABI changes to support FILTER_BYTECODE_MAX_LEN (65536)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 25 lines · * Christian Babeux ([email protected]) wrote:
In order to support the filter bytecode maximum length (65536 bytes), the
lttng_ust_filter_bytecodelen field type must be able to hold more than auint16_t. Change the field type to auint32_t.Also, since the relocation table is located at the end of the actual bytecode, the
reloc_offsetfield must support offset values larger than 65535. Change the field type to auint32_t. This change will allow support of relocation table appended to larger bytecode without breaking the ABI if the need arise in the future.Both changes currently breaks the filter ABI, but this should be a reasonable compromise since the filtering feature has not been released yet.
Signed-off-by Christian Babeux <[email protected]>--- include/lttng/ust-abi.h | 4 ++-- include/ust-comm.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)include/lttng/ust-abi.h +0
-0
include/lttng/ust-abi.h struct lttng_ust_calibrate { · line 178
Quoted 7 lines
include/lttng/ust-abi.h +2
-2@@ -174,8 +174,8 @@ struct lttng_ust_calibrate {#define FILTER_BYTECODE_MAX_LEN 65536struct lttng_ust_filter_bytecode { -uint16_t len; -uint16_t reloc_offset; +uint32_t len; +uint32_t reloc_offset;
You'll need to add a check in liblttng-ust/lttng-ust-comm.c, when the data is received: we need to check that the reloc_offset is within the data.
Mathieu
Quoted 21 lines
include/lttng/ust-abi.h +0
-0char data[0 ]; };include/ust-comm.h +2
-2@@ -132,8 +132,8 @@ struct ustcomm_ust_msg {struct lttng_ust_tracer_version version;struct lttng_ust_tracepoint_iter tracepoint;struct { -uint16_t data_size;/* following filter data */ -uint16_t reloc_offset; +uint32_t data_size;/* following filter data */ +uint32_t reloc_offset; } filter; } u; };Signature · 1 line
1.7.11.4
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
PATCH v2 1/1 Fix: Filter ABI changes to support FILTER_BYTECODE_MAX_LEN (65536)
In reply to a message not in the archivev2 Changelog:
- Add a check when receiving data on the reloc_offset to ensure it lies within the data.
Christian Babeux (1):
Fix: Accept bytecode of length 65536 bytes
include/lttng/ust-abi.h | 4 ++-- include/ust-comm.h | 4 ++-- liblttng-ust/lttng-ust-comm.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.11.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 Fix: Accept bytecode of length 65536 bytes
In order to support the filter bytecode maximum length (65536 bytes), the lttng_ust_filter_bytecode len field type must be able to hold more than a uint16_t. Change the field type to a uint32_t.
Also, since the relocation table is located at the end of the actual bytecode, the reloc_table_offset (reloc_offset in ust-abi) field must support offset values larger than 65535. Change the field type to a uint32_t. This change will allow support of relocation table appended to larger bytecode without breaking the ABI if the need arise in the future.
Both changes currently breaks the filter ABI, but this should be a reasonable compromise since the filtering feature has not been released yet.
--- include/lttng/ust-abi.h | 4 ++-- include/ust-comm.h | 4 ++-- liblttng-ust/lttng-ust-comm.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)
include/lttng/ust-abi.h +2 -2
@@ -174,8 +174,8 @@ struct lttng_ust_calibrate {#define FILTER_BYTECODE_MAX_LEN 65536struct lttng_ust_filter_bytecode { -uint16_t len; -uint16_t reloc_offset; +uint32_t len; +uint32_t reloc_offset;char data[0 ]; };
include/ust-comm.h +2 -2
@@ -132,8 +132,8 @@ struct ustcomm_ust_msg {struct lttng_ust_tracer_version version;struct lttng_ust_tracepoint_iter tracepoint;struct { -uint16_t data_size;/* following filter data */ -uint16_t reloc_offset; +uint32_t data_size;/* following filter data */ +uint32_t reloc_offset; } filter; } u; };
liblttng-ust/lttng-ust-comm.c +8 -0
@@ -293,6 +293,14 @@ int handle_message(struct sock_info *sock_info, ret = -EINVAL ; goto error; } + +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 ; + goto error; + } + bytecode =zmalloc (sizeof (*bytecode) + lum->u.filter.data_size);if (!bytecode) { ret = -ENOMEM ;
Signature · 1 line
1.7.11.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 lttng-ust] Fix: Accept bytecode of length 65536 bytes
Quoted 57 lines · * Christian Babeux ([email protected]) wrote:
In order to support the filter bytecode maximum length (65536 bytes), the
lttng_ust_filter_bytecodelen field type must be able to hold more than auint16_t. Change the field type to auint32_t.Also, since the relocation table is located at the end of the actual bytecode, the
reloc_table_offset(reloc_offsetin ust-abi) field must support offset values larger than 65535. Change the field type to auint32_t. This change will allow support of relocation table appended to larger bytecode without breaking the ABI if the need arise in the future.Both changes currently breaks the filter ABI, but this should be a reasonable compromise since the filtering feature has not been released yet.
Signed-off-by Christian Babeux <[email protected]>--- include/lttng/ust-abi.h | 4 ++-- include/ust-comm.h | 4 ++-- liblttng-ust/lttng-ust-comm.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)include/lttng/ust-abi.h +2
-2@@ -174,8 +174,8 @@ struct lttng_ust_calibrate {#define FILTER_BYTECODE_MAX_LEN 65536struct lttng_ust_filter_bytecode { -uint16_t len; -uint16_t reloc_offset; +uint32_t len; +uint32_t reloc_offset;char data[0 ]; };include/ust-comm.h +2
-2@@ -132,8 +132,8 @@ struct ustcomm_ust_msg {struct lttng_ust_tracer_version version;struct lttng_ust_tracepoint_iter tracepoint;struct { -uint16_t data_size;/* following filter data */ -uint16_t reloc_offset; +uint32_t data_size;/* following filter data */ +uint32_t reloc_offset; } filter; } u; };liblttng-ust/lttng-ust-comm.c +0
-0
liblttng-ust/lttng-ust-comm.c int handle_message(struct sock_info *sock_info, · line 297
Quoted 5 lines
liblttng-ust/lttng-ust-comm.c +2
-0@@ -293,6 +293,14 @@ int handle_message(struct sock_info *sock_info, ret = -EINVAL ; goto error; } + +if (lum->u.filter.reloc_offset > lum->u.filter.data_size) {
if (lum->u.filter.reloc_offset > lum->u.filter.data_size - 1) {
?
Quoted 12 lines
liblttng-ust/lttng-ust-comm.c +6
-0+ERR ("Filter reloc offset %u is not within data\n" , + lum->u.filter.reloc_offset); + ret = -EINVAL ; + goto error; + } + bytecode =zmalloc (sizeof (*bytecode) + lum->u.filter.data_size);if (!bytecode) { ret = -ENOMEM ;Signature · 1 line
1.7.11.4
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
PATCH v3 1/1 Fix: Filter ABI changes to support FILTER_BYTECODE_MAX_LEN (65536)
In reply to a message not in the archiveIn order to support the filter bytecode maximum length (65536 bytes), the lttng_ust_filter_bytecode len field type must be able to hold more than a uint16_t. Change the field type to a uint32_t.
Also, since the relocation table is located at the end of the actual bytecode, the reloc_table_offset (reloc_offset in ust-abi) field must support offset values larger than 65535. Change the field type to a uint32_t. This change will allow support of relocation table appended to larger bytecode without breaking the ABI if the need arise in the future.
Both changes currently breaks the filter ABI, but this should be a reasonable compromise since the filtering feature has not been released yet.
--- include/lttng/ust-abi.h | 4 ++-- include/ust-comm.h | 4 ++-- liblttng-ust/lttng-ust-comm.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)
include/lttng/ust-abi.h +2 -2
@@ -174,8 +174,8 @@ struct lttng_ust_calibrate {#define FILTER_BYTECODE_MAX_LEN 65536struct lttng_ust_filter_bytecode { -uint16_t len; -uint16_t reloc_offset; +uint32_t len; +uint32_t reloc_offset;char data[0 ]; };
include/ust-comm.h +2 -2
@@ -132,8 +132,8 @@ struct ustcomm_ust_msg {struct lttng_ust_tracer_version version;struct lttng_ust_tracepoint_iter tracepoint;struct { -uint16_t data_size;/* following filter data */ -uint16_t reloc_offset; +uint32_t data_size;/* following filter data */ +uint32_t reloc_offset; } filter; } u; };
liblttng-ust/lttng-ust-comm.c +8 -0
@@ -293,6 +293,14 @@ int handle_message(struct sock_info *sock_info, ret = -EINVAL ; goto error; } + +if (lum->u.filter.reloc_offset > lum->u.filter.data_size -1 ) { +ERR ("Filter reloc offset %u is not within data\n" , + lum->u.filter.reloc_offset); + ret = -EINVAL ; + goto error; + } + bytecode =zmalloc (sizeof (*bytecode) + lum->u.filter.data_size);if (!bytecode) { ret = -ENOMEM ;
Signature · 1 line
1.7.11.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mathieu Desnoyers
AppliedQuoted 11 lines · * Christian Babeux ([email protected]) wrote:
In order to support the filter bytecode maximum length (65536 bytes), the
lttng_ust_filter_bytecodelen field type must be able to hold more than auint16_t. Change the field type to auint32_t.Also, since the relocation table is located at the end of the actual bytecode, the
reloc_table_offset(reloc_offsetin ust-abi) field must support offset values larger than 65535. Change the field type to auint32_t. This change will allow support of relocation table appended to larger bytecode without breaking the ABI if the need arise in the future.
Quoted 3 lines
Both changes currently breaks the filter ABI, but this should be a reasonable compromise since the filtering feature has not been released yet.
merged, thanks!
Quoted 60 lines
Signed-off-by Christian Babeux <[email protected]>--- include/lttng/ust-abi.h | 4 ++-- include/ust-comm.h | 4 ++-- liblttng-ust/lttng-ust-comm.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)include/lttng/ust-abi.h +2
-2@@ -174,8 +174,8 @@ struct lttng_ust_calibrate {#define FILTER_BYTECODE_MAX_LEN 65536struct lttng_ust_filter_bytecode { -uint16_t len; -uint16_t reloc_offset; +uint32_t len; +uint32_t reloc_offset;char data[0 ]; };include/ust-comm.h +2
-2@@ -132,8 +132,8 @@ struct ustcomm_ust_msg {struct lttng_ust_tracer_version version;struct lttng_ust_tracepoint_iter tracepoint;struct { -uint16_t data_size;/* following filter data */ -uint16_t reloc_offset; +uint32_t data_size;/* following filter data */ +uint32_t reloc_offset; } filter; } u; };liblttng-ust/lttng-ust-comm.c +8
-0@@ -293,6 +293,14 @@ int handle_message(struct sock_info *sock_info, ret = -EINVAL ; goto error; } + +if (lum->u.filter.reloc_offset > lum->u.filter.data_size -1 ) { +ERR ("Filter reloc offset %u is not within data\n" , + lum->u.filter.reloc_offset); + ret = -EINVAL ; + goto error; + } + bytecode =zmalloc (sizeof (*bytecode) + lum->u.filter.data_size);if (!bytecode) { ret = -ENOMEM ;Signature · 1 line
1.7.11.4
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com