From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 24 18:12:13 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1A05B16A4CE for ; Fri, 24 Sep 2004 18:12:13 +0000 (GMT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B84743D2D for ; Fri, 24 Sep 2004 18:12:12 +0000 (GMT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.13.1/8.13.1) with ESMTP id i8OIBOEr000235; Fri, 24 Sep 2004 14:11:24 -0400 (EDT) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i8OIBJnA000232; Fri, 24 Sep 2004 14:11:19 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Fri, 24 Sep 2004 14:11:19 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: =?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?= In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE cc: bzeeb-lists@lists.zabbadoz.net cc: Mike Meyer cc: Gordon David cc: freebsd-hackers@freebsd.org Subject: Re: execute a user process in the kernel X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Sep 2004 18:12:13 -0000 On Fri, 24 Sep 2004, Dag-Erling Sm=F8rgrav wrote: > execve(2) assumes you already have a process. You get a process by > forking another process. The only process we ever create from scratch > is init(8), and that takes a s**tload of work (see kern/init_main.c).=20 > This is why we have stuff like nfsiod(8) which does nothing but provide > the kernel with a process context it can use for other stuff.=20 >=20 > You could, of course, write a kernel API for creating processes from > scratch. They'd still need a parent, but you can use init(8) (pid 1)=20 > for that.=20 Well, we have kproc/kthread APIs, but none of that is semantically compatible with the notion of execve(), which is a very user-centric concept ("replace the address space with a mapping of binary "). You could fudge together a related notion, though, involving loadable kernel modules that have a main() routine run from a thread. That said, the notion of simply running user code in kernel (as has been pointed out) is fraught with peril, primarily because the kernel is basically one big program with many special requirements, and user applications are written with the assumption that they are the only program, not running in the context of another program. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Principal Research Scientist, McAfee Research