Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jul 2001 23:54:55 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Evan Sarmiento <ems@open-root.org>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: passing function ptrs to syscalls
Message-ID:  <3B5E6D3F.6D5FB1BE@mindspring.com>
References:  <20010723225910.A19663A1DE@postfix.sekt7.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Evan Sarmiento wrote:
> I'm writing a system call which requires a function pointer as an argument,
> In syscalls.master, it is specified as such:
> 
> 366     STD     BSD     { int prfw_inject_fp(int sl, int synum, pid_t pi
> d, int (*fp)() ); }
> 
> However, when I try compiling the kernel, sysproto complains

The parser is s dumb little thing that doesn't understand nesting
of parenthesis.

But even if you fix this, your system call will never work.

The problem is that the system call is in kernel space, but
any function call you can give it is in user space.  This
means that the call you want it to call from kernel space
will not be accessible at the time the call is made.

You also don't want to do this, ever: the kernel runs in
supervisor mode, while your code runs in user mode.  Letting
people execute code in supervisor mode is incredibly fraught
with peril, from a security perspective: anyone who calls
your call can become root, should they choose to write their
credentials off the currently executing proc struct.

The way you would do this, by the way, is to make the call
take a "void *", and then cast it back into a function in
the kernel; this assumes you resolve the address space and
protection domain issues.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B5E6D3F.6D5FB1BE>