[PATCH] Fix umove/umoven return value

Dmitry V. Levin ldv at altlinux.org
Tue Feb 26 02:45:35 UTC 2013


On Tue, Feb 26, 2013 at 02:46:17AM +0100, Ben Noordhuis wrote:
> umoven() uses process_vm_readv() when available but it returns the
> return value of that syscall, which is the number of bytes copied,
> while its callers expect it to simply return zero on success.

Yes, there seems to be a discrepancy.

> It was causing syscalls that take a user-space argument to print
> the abbreviated version, e.g.:
> 
>   epoll_ctl(5, EPOLL_CTL_ADD, 10, {...})
> 
> Instead of:
> 
>   epoll_ctl(5, EPOLL_CTL_ADD, 10, {EPOLLIN, {u32=10, u64=10}})
> 
> * util.c (umoven): Fix return value.
> 
> Signed-off-by: Ben Noordhuis <info at bnoordhuis.nl>
> ---
>  util.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/util.c b/util.c
> index 405670e..af73f09 100644
> --- a/util.c
> +++ b/util.c
> @@ -800,6 +800,8 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
>  				remote, 1,
>  				/*flags:*/ 0
>  		);
> +		if (r == len)
> +			return 0;

This should rather be (r >= 0), and errno != ENOSYS shouldn't fall back to
vm_readv_didnt_work case.

>  		if (r < 0) {
>  			if (errno == ENOSYS)
>  				process_vm_readv_not_supported = 1;
> @@ -807,11 +809,8 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
>  				/* EINVAL or ESRCH could be seen if process is gone,
>  				 * all the rest is strange and should be reported. */
>  				perror_msg("%s", "process_vm_readv");
> -			goto vm_readv_didnt_work;
>  		}
> -		return r;
>  	}
> - vm_readv_didnt_work:
>  
>  	started = 0;
>  	if (addr & (sizeof(long) - 1)) {

-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20130226/4e2b49ed/attachment.bin>


More information about the Strace-devel mailing list