diff mbox series

SUNRPC: Fix general protection fault in trace_rpc_xdr_overflow()

Message ID 160346406748.79082.3077185849414818247.stgit@klimt.1015granger.net
State New
Headers show
Series SUNRPC: Fix general protection fault in trace_rpc_xdr_overflow() | expand

Commit Message

Chuck Lever Oct. 23, 2020, 2:41 p.m. UTC
The TP_fast_assign() section is careful enough not to dereference
xdr->rqst if it's NULL. The TP_STRUCT__entry section is not.

Fixes: 5582863f450c ("SUNRPC: Add XDR overflow trace event")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 include/trace/events/sunrpc.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

J. Bruce Fields Nov. 6, 2020, 10:28 p.m. UTC | #1
Also applied.--b.

On Fri, Oct 23, 2020 at 10:41:07AM -0400, Chuck Lever wrote:
> The TP_fast_assign() section is careful enough not to dereference
> xdr->rqst if it's NULL. The TP_STRUCT__entry section is not.
> 
> Fixes: 5582863f450c ("SUNRPC: Add XDR overflow trace event")
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  include/trace/events/sunrpc.h |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
> index f45b3c01370c..2477014e3fa6 100644
> --- a/include/trace/events/sunrpc.h
> +++ b/include/trace/events/sunrpc.h
> @@ -655,10 +655,10 @@ TRACE_EVENT(rpc_xdr_overflow,
>  		__field(size_t, tail_len)
>  		__field(unsigned int, page_len)
>  		__field(unsigned int, len)
> -		__string(progname,
> -			 xdr->rqst->rq_task->tk_client->cl_program->name)
> -		__string(procedure,
> -			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
> +		__string(progname, xdr->rqst ?
> +			 xdr->rqst->rq_task->tk_client->cl_program->name : "unknown")
> +		__string(procedure, xdr->rqst ?
> +			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name : "unknown")
>  	),
>  
>  	TP_fast_assign(
>
diff mbox series

Patch

diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
index f45b3c01370c..2477014e3fa6 100644
--- a/include/trace/events/sunrpc.h
+++ b/include/trace/events/sunrpc.h
@@ -655,10 +655,10 @@  TRACE_EVENT(rpc_xdr_overflow,
 		__field(size_t, tail_len)
 		__field(unsigned int, page_len)
 		__field(unsigned int, len)
-		__string(progname,
-			 xdr->rqst->rq_task->tk_client->cl_program->name)
-		__string(procedure,
-			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
+		__string(progname, xdr->rqst ?
+			 xdr->rqst->rq_task->tk_client->cl_program->name : "unknown")
+		__string(procedure, xdr->rqst ?
+			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name : "unknown")
 	),
 
 	TP_fast_assign(