[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230623152926.128aa568@gandalf.local.home>
Date: Fri, 23 Jun 2023 15:29:26 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Beau Belgrave <beaub@...ux.microsoft.com>,
Andrew Morton <akpm@...ux-foundation.org>,
sunliming <sunliming@...inos.cn>
Subject: [GIT PULL] tracing: user_event fix for 6.4
Linus,
Tracing fix to user events return value on write
Before user events become an ABI, fix the return value of the write
operation when tracing is disabled. It should not return an error, but
simply report it wrote zero bytes. Just like any other write operation
that doesn't write data but does not "fail".
This also includes test cases for this use case.
Please pull the latest trace-v6.4-rc7 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.4-rc7
Tag SHA1: ec925ce3a8456d2a527572e940ed52123a6083cd
Head SHA1: 131966049074b8025a8cba0e99d3745311fcef5b
sunliming (3):
tracing/user_events: Fix incorrect return value for writing operation when events are disabled
selftests/user_events: Enable the event before write_fault test in ftrace self-test
selftests/user_events: Add test cases when event is disabled
----
kernel/trace/trace_events_user.c | 3 ++-
tools/testing/selftests/user_events/ftrace_test.c | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
---------------------------
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 8df0550415e7..902cae005df4 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -2096,7 +2096,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i)
if (unlikely(faulted))
return -EFAULT;
- }
+ } else
+ return 0;
return ret;
}
diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c
index eb6904d89f14..f42a20520175 100644
--- a/tools/testing/selftests/user_events/ftrace_test.c
+++ b/tools/testing/selftests/user_events/ftrace_test.c
@@ -324,6 +324,9 @@ TEST_F(user, write_events) {
io[0].iov_base = ®.write_index;
io[0].iov_len = sizeof(reg.write_index);
+ /* Write should return zero when event is not enabled */
+ ASSERT_EQ(0, writev(self->data_fd, (const struct iovec *)io, 3));
+
/* Enable event */
self->enable_fd = open(enable_file, O_RDWR);
ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))
@@ -400,6 +403,10 @@ TEST_F(user, write_fault) {
ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®));
ASSERT_EQ(0, reg.write_index);
+ /* Enable event */
+ self->enable_fd = open(enable_file, O_RDWR);
+ ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))
+
/* Write should work normally */
ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 2));
Powered by blists - more mailing lists