Fix: allow racy tracepoint string input from kernel and userspace
[lttng-modules.git] / probes / lttng-events.h
index 680f466f9a2b40531e3214ef551d7296bf024ba1..ab6f342b3e9c8df6c08dc17af8a2203589d3214e 100644 (file)
@@ -691,24 +691,22 @@ __assign_##dest##_3:                                                      \
  */
 #undef tp_copy_string_from_user
 #define tp_copy_string_from_user(dest, src)                            \
-       __assign_##dest:                                                \
-       {                                                               \
-               size_t __ustrlen;                                       \
-                                                                       \
-               if (0)                                                  \
-                       (void) __typemap.dest;                          \
-               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));\
-               __ustrlen = __get_dynamic_array_len(dest);              \
-               if (likely(__ustrlen > 1)) {                            \
-                       __chan->ops->event_write_from_user(&__ctx, src, \
-                               __ustrlen - 1);                         \
-               }                                                       \
-               __chan->ops->event_memset(&__ctx, 0, 1);                \
-       }                                                               \
+__assign_##dest:                                                       \
+       if (0)                                                          \
+               (void) __typemap.dest;                                  \
+       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \
+       __chan->ops->event_strcpy_from_user(&__ctx, src,                \
+               __get_dynamic_array_len(dest));                         \
        goto __end_field_##dest;
+
 #undef tp_strcpy
 #define tp_strcpy(dest, src)                                           \
-       tp_memcpy(dest, src, __get_dynamic_array_len(dest))
+__assign_##dest:                                                       \
+       if (0)                                                          \
+               (void) __typemap.dest;                                  \
+       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \
+       __chan->ops->event_strcpy(&__ctx, src, __get_dynamic_array_len(dest)); \
+       goto __end_field_##dest;
 
 /* Named field types must be defined in lttng-types.h */
 
This page took 0.023661 seconds and 4 git commands to generate.