From: David Goulet Date: Fri, 10 May 2013 17:27:30 +0000 (-0400) Subject: Fix: check channel subbuf size against page size X-Git-Tag: v2.2.0-rc3~90 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=12744796179ed3bfa9c3b6e22bfdeabf2e6081bf;p=lttng-tools.git Fix: check channel subbuf size against page size 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 Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 8f835fd8b..d826125c9 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -25,6 +25,7 @@ #include #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; diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index 9258f38a7..a0916c566 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -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); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 445485b41..952737138 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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) {