Re: Syscall from Kernel Space

From: Jeff Garzik (jgarzik@pobox.com)
Date: Thu Feb 20 2003 - 17:17:30 EST


On Thu, Feb 20, 2003 at 11:10:27PM +0100, Andrea Arcangeli wrote:
> On Thu, Feb 20, 2003 at 12:40:43PM -0500, Jeff Garzik wrote:
> > On Thu, Feb 20, 2003 at 11:04:37PM +0530, Prasad wrote:
> > > Is there a way using which i could invoke a syscall in the kernel
> > > space? The syscall is to be run disguised as another process. The actual
> >
> > Call sys_<syscall>. Look at the kernel code for examples.
> >
> > Note that typically you don't want to do this... and you _really_ don't
> > want to do this if the syscall is not one of the common file I/O
> > syscalls (read/write/open/close, etc.)
>
> you never want to do this, the only point of a syscall is to enter
> kernel, if you're just in kernel you're wasting time in calling the
> syscall (not to tell about the new non soft interrupt based syscall
> instructions, btw this is also why I rejected the int 0x81 thing on
> x86-64 for 64bit syscalls)

He is talking about directly calling the function behind the syscall,
not actually executing a syscall itself.

The kernel already does this in various places. sys_read, sys_write,
open_filp, sys_close, and other functions are safe to call from kernel
code -- though this is discouraged. init/do_mounts.c is a particularly
annoying case, and is a big reason why klibc needs to be merged.
syscalls should be made from userspace, not the kernel.

        Jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Feb 23 2003 - 22:00:31 EST