[PATCH] tracing: Fix tracing buffer length in tracing_mark_write

From: Wang ShaoBo
Date: Tue Jun 23 2020 - 04:52:42 EST


__copy_from_user_inatomic() return the byte length that copied failed,
tracing buffer should left this bytes.

Fixes: 656c7f0d2d2b ("tracing: Replace kmap with copy_from_user() in trace_marker writing")
Signed-off-by: Wang ShaoBo <bobo.shaobowang@xxxxxxxxxx>
---
kernel/trace/trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 29615f15a820..ed5fe0f165e0 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6628,7 +6628,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
written = -EFAULT;
} else
written = cnt;
- len = cnt;
+ cnt -= len;

if (tr->trace_marker_file && !list_empty(&tr->trace_marker_file->triggers)) {
/* do not add \n before testing triggers, but add \0 */
--
2.17.1