[PATCH] Fix umove/umoven return value

Denys Vlasenko dvlasenk at redhat.com
Tue Feb 26 11:32:40 UTC 2013


On 02/26/2013 04:07 AM, Ben Noordhuis wrote:
> On Tue, Feb 26, 2013 at 3:45 AM, Dmitry V. Levin <ldv at altlinux.org> wrote:
>>> 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.
> 
> r >= 0 seems less safe than r == len.  What if you get less bytes than expected?

In fact old code (one which uses PTRACE_PEEKDATA) does return 0
on short reads... but I think you are right, it's not what it should do.

I propose that we comment out old code for now:

#if 0
//FIXME: wrong. printpath doesn't use this routine. Callers expect full copies.
//Ok to remove?
                        if (started && (errno==EPERM || errno==EIO)) {
                                /* Ran into 'end of memory' - stupid "printpath" */
                                return 0;
                        }
#endif

and we can delete it later (or uncomment if I'm wrong).

> The errno != ENOSYS flow is unchanged, it was already like that.

I am adding an error message on "r < len" code path.

Applied, thanks!

-- 
vda




More information about the Strace-devel mailing list