lkml.org 
[lkml]   [2008]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch 7/9] fs/exec.c: fix wrong return value of prepare_binprm()
On Mon, May 12, 2008 at 05:01:22AM +0100, Al Viro wrote:
>On Mon, May 12, 2008 at 11:56:43AM +0800, WANG Cong wrote:
>> On Sat, May 10, 2008 at 08:31:05PM +0100, Al Viro wrote:
>> >On Thu, May 08, 2008 at 09:52:32PM +0800, WANG Cong wrote:
>> >> All prepare_binprm()'s callers assume that prepare_binprm() fails
>> >> when it returns negative. However, prepare_binprm() most probably returns
>> >> the return value of kernel_read(), which may return positive on failure!
>> >>
>> >> Thus this should be fixed.
>> >
>> >Since when does read return positive on failure?
>>
>> When an EIO occurs, I think. For example,
>
>No. On EIO it returns -EIO, TYVM...
>

Hmm, it should. Thanks for your correction.


>> retval = kernel_read(interpreter, interp_elf_ex->e_phoff,
>> (char *)elf_phdata,size);
>> error = -EIO;
>> if (retval != size) {
>> if (retval < 0)
>> error = retval;
>> goto out_close;
>> }
>
>Which is what we do on short read here. FWIW, -EINVAL might be saner
>choice - it's "binary is corrupted", not "read had failed".

IMO, -EIO is fine, because -EINVAL means "Invalid argument", but
there's nothing wrong with arguments here, just some bad things occurred
on reading the binary.

And even if it is really "binary is corrupted", then -ENOEXEC is
better than -EINVAL, isn't it?

Anyway, kernel_read() may return postive when not success.

Thanks.

--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.


\
 
 \ /
  Last update: 2008-05-12 06:25    [W:0.140 / U:0.128 seconds]
©2003-2014 Jasper Spaans. Advertise on this site