Re: [PATCH] Return real errno from execve in ____call_usermodehelper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 19, 2006 at 01:14:28AM -0700, Andrew Morton wrote:
> On Sat, 19 Aug 2006 09:30:31 +0200
> Bj?rn Steinbrink <[email protected]> wrote:
> 
> > If execve fails in ____call_usermodehelper we treat its return value as
> > error code, but as execve is a syscall, we actually want -errno there.
> > 
> > Signed-off-by: Bj?rn Steinbrink <[email protected]>
> > 
> > --
> > 
> > diff --git a/kernel/kmod.c b/kernel/kmod.c
> > index 1d32def..865abc0 100644
> > --- a/kernel/kmod.c
> > +++ b/kernel/kmod.c
> > @@ -149,8 +149,10 @@ static int ____call_usermodehelper(void 
> >  	set_cpus_allowed(current, CPU_MASK_ALL);
> >  
> >  	retval = -EPERM;
> > -	if (current->fs->root)
> > -		retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
> > +	if (current->fs->root) {
> > +		execve(sub_info->path, sub_info->argv, sub_info->envp);
> > +		retval = -errno;
> > +	}
> >  
> >  	/* Exec failed? */
> >  	sub_info->retval = retval;
> 
> ug.  I wish we could find some way of using do_execve() here.  Or hoist
> sys_execve() out of the architectures.

Some architectures do implement their own special execve() function,
some of which are written for how this code above currently is (iow,
not using errno) and are probably buggy in that respect.

Maybe what we should be thinking of doing is changing execve() calls
to kernel_execve() which returns the error code.

This way, architectures are free to implement execve() whatever way
they wish - and if they're concerned about using errno, that's their
own implementation specific detail.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux