Re: [PATCH] introduce kernel_execve function to replace __KERNEL_SYSCALLS__

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

 



On Sunday 20 August 2006 12:13, Arnd Bergmann wrote:

> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-cg/lib/execve.c	2006-08-20 19:06:00.000000000 +0200
> @@ -0,0 +1,19 @@
> +#include <asm/bug.h>
> +#include <asm/uaccess.h>
> +
> +#define __KERNEL_SYSCALLS__
> +static int errno;
> +#include <asm/unistd.h>
> +
> +int kernel_execve(const char *filename, char *const argv[], char *const
> envp[]) +{
> +	mm_segment_t fs = get_fs();
> +	int ret;
> +
> +	WARN_ON(segment_eq(fs, USER_DS));
> +	ret = execve(filename, (char **)argv, (char **)envp);
> +	if (ret)
> +		ret = errno;
> +
> +	return ret;
> +}

I noticed this global errno in lib/errno.c a while ago and was wondering what 
the right way to clean it up is. From what I remember, no one actually uses 
errno in the kernel (unless it's an "errno" they've defined locally). The 
only other place errno gets used is by all of the syscall macros.

Unless there's some TLS kernel magic that I've totally missed, using errno in 
this manner is totally unsafe anyway. So I would NAK the above because your 
kernel_execve() function gives an unsafe errno value significance it should 
not have by turning it into a return value. (As an aside, shouldn't that have 
read [ ret = -errno; ] anyway?)

Unless 'errno' has some significant reason to live on in the kernel, I think 
it would be better to kill it and write kernel syscall macros that don't muck 
with it.

Thanks,
Chase
-
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