Fix: handle capture page faults as skip field
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 27 Sep 2022 20:31:29 +0000 (16:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 28 Sep 2022 18:21:45 +0000 (14:21 -0400)
Now that we have the appropriate save/restore position mechanism for
error handling in place, we can handle page faults on copy-from-user by
skipping the offending captured field entirely rather than relying on an
empty string.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibe1e818f57f8218d2b83281a572895884fc28b86

src/lib/msgpack/msgpack.c

index b9bac85f64ff8766ef6ec032bf9cee420ff8229d..54d5692679cd926fec304dc4bff0821142e6197e 100644 (file)
@@ -130,10 +130,7 @@ static inline int lttng_msgpack_append_user_buffer(
        }
 
        if (lttng_copy_from_user_check_nofault(writer->write_pos, ubuf, length)) {
-               /*
-                * After a successful strlen user, a page fault on copy is handled by
-                * considering the string as empty, returning a success.
-                */
+               ret = -1;
                goto end;
        }
        writer->write_pos += length;
@@ -444,12 +441,6 @@ int lttng_msgpack_write_user_str(struct lttng_msgpack_writer *writer,
                goto end;
        }
 
-       /*
-        * Handle empty string and strlen user page fault as empty string.
-        */
-       if (length == 1)
-               return lttng_msgpack_write_str(writer, "");
-
        if (length <= MSGPACK_FIXSTR_MAX_LENGTH)
                ret = lttng_msgpack_encode_user_fixstr(writer, ustr, length);
        else
This page took 0.026771 seconds and 4 git commands to generate.