From owner-freebsd-hackers Tue Jul 24 23:54:43 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by hub.freebsd.org (Postfix) with ESMTP id 5B71A37B401 for ; Tue, 24 Jul 2001 23:54:40 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from mindspring.com (dialup-209.245.141.74.Dial1.SanJose1.Level3.net [209.245.141.74]) by snipe.mail.pas.earthlink.net (EL-8_9_3_3/8.9.3) with ESMTP id XAA01621; Tue, 24 Jul 2001 23:54:16 -0700 (PDT) Message-ID: <3B5E6D3F.6D5FB1BE@mindspring.com> Date: Tue, 24 Jul 2001 23:54:55 -0700 From: Terry Lambert Reply-To: tlambert2@mindspring.com X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Evan Sarmiento Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: passing function ptrs to syscalls References: <20010723225910.A19663A1DE@postfix.sekt7.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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