Secure user authentication for NFS using RPCSEC_GSS [2/6]
Subsystems (3)
PATCH 1/1 Secure user authentication for NFS using RPCSEC_GSS [2/6]
The RPCSEC_GSS user context defines a 'sequence number' in the AUTH header fields in order to provide protection against replay attacks. This number needs to lie within a given 'window', and is required to be updated even when retransmitting dropped requests.
In order to allow this update to occur, move the XDR 'encode' phase so that it is done immediately before writing the data to the socket.
Cheers,
Trond
include/linux/sunrpc/xprt.h +1 -0
@@ -187,6 +187,7 @@ unsigned long);void xprt_reserve (struct rpc_task *); +int xprt_prepare_transmit (struct rpc_task *);void xprt_transmit (struct rpc_task *);void xprt_receive (struct rpc_task *);int xprt_adjust_timeout (struct rpc_timeout *);
net/sunrpc/clnt.c +16 -8
@@ -470,7 +470,7 @@dprintk ("RPC: %4d call_allocate (status %d)\n" , task->tk_pid, task->tk_status); - task->tk_action = call_encode; + task->tk_action = call_bind;if (task->tk_buffer)return ;
@@ -510,8 +510,6 @@dprintk ("RPC: %4d call_encode (status %d)\n" , task->tk_pid, task->tk_status); - task->tk_action = call_bind; -/* Default buffer setup */ bufsiz = task->tk_bufsize >>1 ; sndbuf->head[0 ].iov_base = (void *)task->tk_buffer;
@@ -533,7 +531,8 @@if (!(p =call_header (task))) {printk (KERN_INFO "RPC: call_header failed, exit EIO\n" );rpc_exit (task, -EIO ); - }else +return ; + }if (encode && (status =encode (req, p, task->tk_msg.rpc_argp)) <0 ) {printk (KERN_WARNING "%s: can't encode arguments: %d\n" , clnt->cl_protname, -status);
@@ -617,8 +616,17 @@ task->tk_action = call_status;if (task->tk_status <0 )return ; + task->tk_status =xprt_prepare_transmit (task); +if (task->tk_status <0 ) +return ; +/* Encode here so that rpcsec_gss can use correct sequence number. */ +call_encode (task); +if (task->tk_status <0 ) +return ;xprt_transmit (task); -if (!task->tk_msg.rpc_proc->p_decode && task->tk_status >=0 ) { +if (task->tk_status <0 ) +return ; +if (!task->tk_msg.rpc_proc->p_decode) { task->tk_action =NULL ;rpc_wake_up_task (task); }
@@ -758,7 +766,7 @@if (RPC_IS_SETUID (task) && task->tk_suid_retry) {dprintk ("RPC: %4d retry squashed uid\n" , task->tk_pid); task->tk_flags ^=RPC_CALL_REALUID ; - task->tk_action = call_encode; + task->tk_action = call_bind; task->tk_suid_retry--;return ; }
@@ -864,7 +872,7 @@ task->tk_garb_retry--;dprintk ("RPC: %4d call_verify: retry garbled creds\n" , task->tk_pid); - task->tk_action = call_encode; + task->tk_action = call_bind;return NULL ;case RPC_AUTH_TOOWEAK : printk(KERN_NOTICE "call_verify: server requires stronger "
@@ -899,7 +907,7 @@if (task->tk_garb_retry) { task->tk_garb_retry--;dprintk (KERN_WARNING "RPC: garbage, retrying %4d\n" , task->tk_pid); - task->tk_action = call_encode; + task->tk_action = call_bind;return NULL ; }printk (KERN_WARNING "RPC: garbage, exit EIO\n" );
net/sunrpc/xprt.c +22 -24
86 lines not on this page · raw message