Fix: deny overwrite mode and num subbuf less than 2
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 2a61eee064f5af2fa558e73db87f2057fd8eb120..9ef9686bd40b3c29727451a9d52d11a4367e64f0 100644 (file)
@@ -850,6 +850,16 @@ int cmd_enable_channel(struct ltt_session *session,
 
        rcu_read_lock();
 
+       /*
+        * The ringbuffer (both in user space and kernel) behave badly in overwrite
+        * mode and with less than 2 subbuf so block it right away and send back an
+        * invalid attribute error.
+        */
+       if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
+               ret = LTTNG_ERR_INVALID;
+               goto error;
+       }
+
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -2301,6 +2311,21 @@ int cmd_data_pending(struct ltt_session *session)
        if (session->enabled) {
                ret = LTTNG_ERR_SESSION_STARTED;
                goto error;
+       } else {
+               /*
+                * If stopped, just make sure we've started before else the above call
+                * will always send that there is data pending.
+                *
+                * The consumer assumes that when the data pending command is received,
+                * the trace has been started before or else no output data is written
+                * by the streams which is a condition for data pending. So, this is
+                * *VERY* important that we don't ask the consumer before a start
+                * trace.
+                */
+               if (!session->started) {
+                       ret = 0;
+                       goto error;
+               }
        }
 
        if (ksess && ksess->consumer) {
This page took 0.024404 seconds and 4 git commands to generate.