Fix: test for UST invalid channel parameters at channel creation
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 8 Mar 2012 16:07:13 +0000 (11:07 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 8 Mar 2012 16:07:13 +0000 (11:07 -0500)
Acked-by: David Goulet <dgoulet@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-sessiond/channel.c
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h

index 54345d9c94bfa96a70ab9cd0ab6ffb925a9d4953..58a36b97c8b2f54085ed0b2ad463ef005c68d53a 100644 (file)
@@ -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) {
index e767c5c2347ba2908b1137259ee8395ee1653c7c..5f086141dd7b2af44954c9ab93edf0078fdcddd2 100644 (file)
@@ -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",
 };
 
 /*
index 73abfe84aa41c5315120f35cb60a3b7317a10e94..b98f9fc228fa7dedfee2feab8f28e4eec8de51ba 100644 (file)
@@ -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 */
This page took 0.036151 seconds and 4 git commands to generate.