Fix: check channel subbuf size against page size
authorDavid Goulet <dgoulet@efficios.com>
Fri, 10 May 2013 17:27:30 +0000 (13:27 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 10 May 2013 17:47:11 +0000 (13:47 -0400)
Don't validate channel subbuffer size against the default values but
rather against the lower bound being the page size taken at runtime.

Reported-by: Tan Dung Le Tran <tan.dung.le.tran@ericsson.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/lttng-sessiond.h
src/bin/lttng-sessiond/main.c

index 8f835fd8b6276385dd9bc068dca7a92b0202233e..d826125c9b8c7acaf5a57f294aeb7d29f78803ea 100644 (file)
@@ -25,6 +25,7 @@
 #include <common/sessiond-comm/sessiond-comm.h>
 
 #include "channel.h"
+#include "lttng-sessiond.h"
 #include "kernel.h"
 #include "ust-ctl.h"
 #include "utils.h"
@@ -273,6 +274,14 @@ int channel_ust_create(struct ltt_ust_session *usess,
                goto error;
        }
 
+       /*
+        * Invalid subbuffer size if it's lower then the page size.
+        */
+       if (attr->attr.subbuf_size < page_size) {
+               ret = LTTNG_ERR_INVALID;
+               goto error;
+       }
+
        if (!attr->attr.num_subbuf ||
                        (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
                ret = LTTNG_ERR_INVALID;
@@ -297,18 +306,8 @@ int channel_ust_create(struct ltt_ust_session *usess,
        /* Validate buffer type. */
        switch (type) {
        case LTTNG_BUFFER_PER_PID:
-               if (attr->attr.subbuf_size <
-                               default_get_ust_pid_channel_subbuf_size()) {
-                       ret = LTTNG_ERR_INVALID;
-                       goto error;
-               }
                break;
        case LTTNG_BUFFER_PER_UID:
-               if (attr->attr.subbuf_size <
-                               default_get_ust_uid_channel_subbuf_size()) {
-                       ret = LTTNG_ERR_INVALID;
-                       goto error;
-               }
                break;
        default:
                ret = LTTNG_ERR_BUFFER_NOT_SUPPORTED;
index 9258f38a7c1018d27ee91de0f3817f92efe90bd6..a0916c5663cdb4394f581f8c2abcaaec54fa8c45 100644 (file)
@@ -71,6 +71,11 @@ struct ust_cmd_queue {
  */
 extern int apps_cmd_notify_pipe[2];
 
+/*
+ * Populated when the daemon starts with the current page size of the system.
+ */
+extern long page_size;
+
 int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
 int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
 
index 445485b417d5d0b0e0cd6f1de4eaab41336baaf5..9527371380e02c45011ad60a0f806872e194a861 100644 (file)
@@ -232,6 +232,9 @@ static enum consumerd_state kernel_consumerd_state;
  */
 static int app_socket_timeout;
 
+/* Set in main() with the current page size. */
+long page_size;
+
 static
 void setup_consumerd_path(void)
 {
@@ -4038,6 +4041,13 @@ int main(int argc, char **argv)
 
        setup_consumerd_path();
 
+       page_size = sysconf(_SC_PAGESIZE);
+       if (page_size < 0) {
+               PERROR("sysconf _SC_PAGESIZE");
+               page_size = LONG_MAX;
+               WARN("Fallback page size to %ld", page_size);
+       }
+
        /* Parse arguments */
        progname = argv[0];
        if ((ret = parse_args(argc, argv)) < 0) {
This page took 0.030189 seconds and 5 git commands to generate.