From 96c55c2f6b20fd742b3ea2aa291c28e140df82d8 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 17 May 2016 21:16:22 -0400 Subject: [PATCH] Fix: compat ioctl for flush/get metadata version Unlike the non-compat version, the compat ioctl lttng ABI code for the ring buffer flush operation does not invoke lttng_metadata_output_channel before calling the ring buffer operation. This could lead to incomplete metadata on 64-bit kernels running with 32-bit lttng userland. There is also a discrepancy between the non-compat and compat code: the GET_METADATA_VERSION operation is performed before calling the ring buffer code. Ensure both non-compat and compat code are alike. Signed-off-by: Mathieu Desnoyers --- lttng-abi.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lttng-abi.c b/lttng-abi.c index c14cc82b..87465189 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -757,6 +757,27 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp, */ return -ENOSYS; } + case RING_BUFFER_FLUSH: + { + struct lttng_metadata_stream *stream = filp->private_data; + struct lib_ring_buffer *buf = stream->priv; + struct channel *chan = buf->backend.chan; + + /* + * Before doing the actual ring buffer flush, write up to one + * packet of metadata in the ring buffer. + */ + ret = lttng_metadata_output_channel(stream, chan); + if (ret < 0) + goto err; + break; + } + case RING_BUFFER_GET_METADATA_VERSION: + { + struct lttng_metadata_stream *stream = filp->private_data; + + return put_u64(stream->version, arg); + } default: break; } @@ -774,12 +795,6 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp, cmd, arg); break; } - case RING_BUFFER_GET_METADATA_VERSION: - { - struct lttng_metadata_stream *stream = filp->private_data; - - return put_u64(stream->version, arg); - } default: break; } -- 2.34.1