X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fprobes%2Flttng-probe-user.c;h=91190f7ba6e3152ea643a2c44b28bb7b7b2b97be;hb=6f192a1604eccbbd6d2622edb51570b2862ac93f;hp=009cfed004c65d124229301365df8582f896db53;hpb=cfa6cc1d0f01c2cfcc1a679abf3a6572d411c309;p=lttng-modules.git diff --git a/src/probes/lttng-probe-user.c b/src/probes/lttng-probe-user.c index 009cfed0..91190f7b 100644 --- a/src/probes/lttng-probe-user.c +++ b/src/probes/lttng-probe-user.c @@ -10,6 +10,8 @@ #include #include +#define LTTNG_MAX_USER_STRING_LEN 1048576 /* 1MB */ + /* * Calculate string length. Include final null terminating character if there is * one, or ends at first fault. Disabling page faults ensures that we can safely @@ -19,13 +21,10 @@ long lttng_strlen_user_inatomic(const char *addr) { long count = 0; - mm_segment_t old_fs; if (!addr) return 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); pagefault_disable(); for (;;) { char v; @@ -41,12 +40,13 @@ long lttng_strlen_user_inatomic(const char *addr) if (unlikely(ret > 0)) break; count++; + if (unlikely(count > LTTNG_MAX_USER_STRING_LEN)) + break; if (unlikely(!v)) break; addr++; } pagefault_enable(); - set_fs(old_fs); return count; } EXPORT_SYMBOL_GPL(lttng_strlen_user_inatomic);