]> Pileus Git - ~andy/linux/blobdiff - kernel/trace/trace.c
tracing: Fix potential out-of-bounds in trace_get_user()
[~andy/linux] / kernel / trace / trace.c
index d5f7c4d84bcdbb1d38f94f5e0748e433382a8879..063a92bad5786d4326a76140647ddc78ead4f784 100644 (file)
@@ -843,9 +843,12 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
        if (isspace(ch)) {
                parser->buffer[parser->idx] = 0;
                parser->cont = false;
-       } else {
+       } else if (parser->idx < parser->size - 1) {
                parser->cont = true;
                parser->buffer[parser->idx++] = ch;
+       } else {
+               ret = -EINVAL;
+               goto out;
        }
 
        *ppos += read;