Trying to see better how the metadata size was handled, I ended up doing
a couple of modifications to the size value sent by the sender: given
that this header contains a size value that should cover both the
metadata packet header size, and the following payload size (this is how
kernel splice sent behaves), I modified kernel/UST mmap to do the same.
I therefore changed the recently updated recv_metadata payload size
calculation to match the encoded size, which should hopefully work for
all kernel splice/mmap and UST mmap cases.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
- data_size = be64toh(recv_hdr->data_size);
- payload_size = data_size;
- /*
- * Add 8 bytes (uint64_t) to the data size which is the value of the
- * stream_id and the payload size.
- */
- data_size += sizeof(uint64_t);
+ data_size = payload_size = be64toh(recv_hdr->data_size);
+ if (data_size < sizeof(struct lttcomm_relayd_metadata_payload)) {
+ ERR("Incorrect data size");
+ ret = -1;
+ goto end;
+ }
+ payload_size -= sizeof(struct lttcomm_relayd_metadata_payload);
+
if (data_buffer_size < data_size) {
data_buffer = realloc(data_buffer, data_size);
if (!data_buffer) {
if (data_buffer_size < data_size) {
data_buffer = realloc(data_buffer, data_size);
if (!data_buffer) {
/* Handle stream on the relayd if the output is on the network */
if (relayd) {
/* Handle stream on the relayd if the output is on the network */
if (relayd) {
+ unsigned long netlen = len;
+
/*
* Lock the control socket for the complete duration of the function
* since from this point on we will use the socket.
/*
* Lock the control socket for the complete duration of the function
* since from this point on we will use the socket.
if (stream->metadata_flag) {
/* Metadata requires the control socket. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
if (stream->metadata_flag) {
/* Metadata requires the control socket. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
+ netlen += sizeof(stream->relayd_stream_id);
- ret = consumer_handle_stream_before_relayd(stream, len);
+ ret = consumer_handle_stream_before_relayd(stream, netlen);
if (ret >= 0) {
/* Use the returned socket. */
outfd = ret;
if (ret >= 0) {
/* Use the returned socket. */
outfd = ret;
/* Handle stream on the relayd if the output is on the network */
if (relayd) {
/* Handle stream on the relayd if the output is on the network */
if (relayd) {
+ unsigned long netlen = len;
+
if (stream->metadata_flag) {
/* Only lock if metadata since we use the control socket. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
if (stream->metadata_flag) {
/* Only lock if metadata since we use the control socket. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
+ netlen += sizeof(stream->relayd_stream_id);
- ret = consumer_handle_stream_before_relayd(stream, len);
+ ret = consumer_handle_stream_before_relayd(stream, netlen);
if (ret >= 0) {
outfd = ret;
if (ret >= 0) {
outfd = ret;