Fix: test for UST invalid channel parameters at channel creation
[lttng-tools.git] / src / bin / lttng-sessiond / channel.c
index 23b3b1feea0050490e3a895d3054507e91a88536..58a36b97c8b2f54085ed0b2ad463ef005c68d53a 100644 (file)
@@ -194,7 +194,7 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_EXEC_NAME:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
@@ -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) {
@@ -256,7 +271,7 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_EXEC_NAME:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error_free_chan;
        }
 
@@ -313,7 +328,7 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_PID:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
This page took 0.025773 seconds and 5 git commands to generate.