From: Mathieu Desnoyers Date: Thu, 8 Mar 2012 16:07:13 +0000 (-0500) Subject: Fix: test for UST invalid channel parameters at channel creation X-Git-Tag: v2.0.0-rc3~10 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b024d072031acc6eec7e083de606fbce11aab882;p=lttng-tools.git Fix: test for UST invalid channel parameters at channel creation Acked-by: David Goulet Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 54345d9c9..58a36b97c 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -235,6 +235,21 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, attr = defattr; } + /* + * Validate UST buffer size and number of buffers: must both be + * power of 2 and nonzero. We validate right here for UST, + * because applications will not report the error to the user + * (unlike kernel tracing). + */ + if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) { + ret = LTTCOMM_INVALID; + goto error; + } + if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) { + ret = LTTCOMM_INVALID; + goto error; + } + /* Create UST channel */ uchan = trace_ust_create_channel(attr, usess->pathname); if (uchan == NULL) { diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index e767c5c23..5f086141d 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -120,6 +120,7 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ENOMEM) ] = "consumerd splice ENOMEM", [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ESPIPE) ] = "consumerd splice ESPIPE", [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_EVENT) ] = "Event not found", + [ LTTCOMM_ERR_INDEX(LTTCOMM_INVALID) ] = "Invalid parameter", }; /* diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 73abfe84a..b98f9fc22 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -154,6 +154,7 @@ enum lttcomm_return_code { CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */ CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ + LTTCOMM_INVALID, /* Invalid parameter */ /* MUST be last element */ LTTCOMM_NR, /* Last element */