From 33fbd46910b681a74b2493cff8c86979ec35ccc9 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 23 May 2014 10:32:09 -0400 Subject: [PATCH] Fix: deny overwrite mode and num subbuf less than 2 Also fixed in UST and modules with commit: (modules) 5140d2b3070f211e6d8a0ad7cb0a190e8b6f3e28 (ust) 3d8e9399b2fb9000b3b55e488a7d04184b5bb56e Fixes #793 Signed-off-by: David Goulet --- doc/man/lttng.1 | 3 ++- src/bin/lttng-sessiond/cmd.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/man/lttng.1 b/doc/man/lttng.1 index 483df2aef..09c77d1d3 100644 --- a/doc/man/lttng.1 +++ b/doc/man/lttng.1 @@ -402,7 +402,8 @@ Apply to the user-space tracer Discard event when subbuffers are full (default) .TP .BR "\-\-overwrite" -Flight recorder mode : overwrites events when subbuffers are full +Flight recorder mode: overwrites events when subbuffers are full. The +number of subbuffer must be 2 or more. .TP .BR "\-\-subbuf-size SIZE" Subbuffer size in bytes {+k,+M,+G}. diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index eb516d3b1..2536dc72d 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -933,6 +933,16 @@ int cmd_enable_channel(struct ltt_session *session, attr->attr.switch_timer_interval = 0; } + /* + * 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: { -- 2.34.1