public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [Libtirpc-devel] [libtirpc-devel] [PATCH] Fix write retry loop for nonblocking mode
       [not found] <d6437a$66h60b@dgate10u.abg.fsc.net>
@ 2014-11-06 18:34 ` Steve Dickson
  0 siblings, 0 replies; only message in thread
From: Steve Dickson @ 2014-11-06 18:34 UTC (permalink / raw)
  To: bstroesser, libtirpc-devel, nfs >> Linux NFS Mailing list



On 09/30/2014 09:17 AM, bstroesser@ts.fujitsu.com wrote:
> Hello,
> 
> while testing with rpcbind, I stumbled across a small
> bug in libtirpc. I didn't test the patch below, but
> I think it's quite obvious.
> 
> Please CC me, I'm not on the list.
> 
> Best regards
> Bodo
> 
> 
> ----------
> 
> From: Bodo Stroesser <bstroesser@ts.fujitsu.com>
> Date: Tue, 30 Sep 2014 14:01:17 +0200
> Subject: [PATCH] fix write retry loop for nonblocking mode
> 
> This is a simple fix for the write retry loop that is used on
> non-blocking connections if write() failed with -EAGAIN.
> 
> Additionally it removes a redundant if () {}
> 
> Erroneously at each cycle of the loop the length of the data
> to send is incremented and the buffer pointer is decremented.
> Thus, it might happen that:
> * the application crashes
> * data from the memory before the buffer is sent
> 
> Signed-off-by: Bodo Stroesser <bstroesser@ts.fujitsu.com>
Committed....

steved.

> 
> ---------
> 
> --- libtirpc-0.2.5/src/svc_vc.c	2014-09-30 14:56:42.000000000 +0200
> +++ libtirpc-0.2.5/src/svc_vc.c	2014-09-30 15:03:56.000000000 +0200
> @@ -559,20 +559,19 @@ write_vc(xprtp, buf, len)
>  				cd->strm_stat = XPRT_DIED;
>  				return (-1);
>  			}
> -			if (cd->nonblock && i != cnt) {
> -				/*
> -				 * For non-blocking connections, do not
> -				 * take more than 2 seconds writing the
> -				 * data out.
> -				 *
> -				 * XXX 2 is an arbitrary amount.
> -				 */
> -				gettimeofday(&tv1, NULL);
> -				if (tv1.tv_sec - tv0.tv_sec >= 2) {
> -					cd->strm_stat = XPRT_DIED;
> -					return (-1);
> -				}
> +			/*
> +			 * For non-blocking connections, do not
> +			 * take more than 2 seconds writing the
> +			 * data out.
> +			 *
> +			 * XXX 2 is an arbitrary amount.
> +			 */
> +			gettimeofday(&tv1, NULL);
> +			if (tv1.tv_sec - tv0.tv_sec >= 2) {
> +				cd->strm_stat = XPRT_DIED;
> +				return (-1);
>  			}
> +			i = 0; /* Don't change buf and cnt */
>  		}
>  	}
>  
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
> _______________________________________________
> Libtirpc-devel mailing list
> Libtirpc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libtirpc-devel
> 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-11-06 18:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <d6437a$66h60b@dgate10u.abg.fsc.net>
2014-11-06 18:34 ` [Libtirpc-devel] [libtirpc-devel] [PATCH] Fix write retry loop for nonblocking mode Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox