diff mbox series

tracing/user_events: Fix the incorrect trace record for null arguments events

Message ID 20230601094158.575019-1-sunliming@kylinos.cn (mailing list archive)
State Superseded
Headers show
Series tracing/user_events: Fix the incorrect trace record for null arguments events | expand

Commit Message

sunliming June 1, 2023, 9:41 a.m. UTC
The user_events support events that has null arguments. But the trace event
is discard and not really committed when the arguments is null, fix this
problem.

Signed-off-by: sunliming <sunliming@kylinos.cn>
---
 kernel/trace/trace_events_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Beau Belgrave June 1, 2023, 3:30 p.m. UTC | #1
On Thu, Jun 01, 2023 at 05:41:58PM +0800, sunliming wrote:
> The user_events support events that has null arguments. But the trace event
> is discard and not really committed when the arguments is null, fix this
> problem.
> 

Thanks for the patch, this is a good catch! Can you reword this a bit?
"fix this problem" could be reworded to "Fix this by not attempting to
copy in non-zero data".

Would you mind adding this case to either the perf or ftrace self-test?
It's a really good edge case.

Thanks,
-Beau

> Signed-off-by: sunliming <sunliming@kylinos.cn>
> ---
>  kernel/trace/trace_events_user.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
> index 0d91dac206ff..296bdfa674cb 100644
> --- a/kernel/trace/trace_events_user.c
> +++ b/kernel/trace/trace_events_user.c
> @@ -1399,7 +1399,7 @@ static void user_event_ftrace(struct user_event *user, struct iov_iter *i,
>  	if (unlikely(!entry))
>  		return;
>  
> -	if (unlikely(!copy_nofault(entry + 1, i->count, i)))
> +	if (unlikely(i->count && !copy_nofault(entry + 1, i->count, i)))
>  		goto discard;
>  
>  	if (!list_empty(&user->validators) &&
> @@ -1440,7 +1440,7 @@ static void user_event_perf(struct user_event *user, struct iov_iter *i,
>  
>  		perf_fetch_caller_regs(regs);
>  
> -		if (unlikely(!copy_nofault(perf_entry + 1, i->count, i)))
> +		if (unlikely(i->count && !copy_nofault(perf_entry + 1, i->count, i)))
>  			goto discard;
>  
>  		if (!list_empty(&user->validators) &&
> -- 
> 2.25.1
diff mbox series

Patch

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 0d91dac206ff..296bdfa674cb 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1399,7 +1399,7 @@  static void user_event_ftrace(struct user_event *user, struct iov_iter *i,
 	if (unlikely(!entry))
 		return;
 
-	if (unlikely(!copy_nofault(entry + 1, i->count, i)))
+	if (unlikely(i->count && !copy_nofault(entry + 1, i->count, i)))
 		goto discard;
 
 	if (!list_empty(&user->validators) &&
@@ -1440,7 +1440,7 @@  static void user_event_perf(struct user_event *user, struct iov_iter *i,
 
 		perf_fetch_caller_regs(regs);
 
-		if (unlikely(!copy_nofault(perf_entry + 1, i->count, i)))
+		if (unlikely(i->count && !copy_nofault(perf_entry + 1, i->count, i)))
 			goto discard;
 
 		if (!list_empty(&user->validators) &&