🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1146

Re: Mach messaging to kernel server vs. "traditional" kernel drivers

#1146
From: Chris Lloyd
Date: Fri, 14 Aug 1992 20:32
53 lines
3337 bytes
In article <1992Aug14.133748.29123@ni.umd.edu> louie@sayshell.umd.edu (Louis A. Mamakos) writes:
>I'm doing a different driver which needs similar functions, but am
>considering using Mach messaging rather than a character special
>device to do what I want.  Now, one thing which I'm trying to
>determine how to implement with the Mach messaging design is how to do
>access control and credentials checking.  With the tradional UNIX
>device driver, I can use suser() to protect access to certain
>protected functions.  How can I determine the identity, in some useful
>sense, of the sender in the Mach messaging case?

The easiest way to do the equiv. of suser() is to pass the host_priv_self()
port around:

For the calls that require super user privileges, add another parameter
to the RPC of type port_t.
In the kernel server, when those calls come in, compare the port_t to
host_priv_self(), the port passed from the client will either map correctly
into the same port # or won't, sorta like a ticket required to do things.
The client side is then required to pass host_priv_self() for those calls
or they'll fail (host_priv_self() requires you to be root).

If you want more granular crendential checking, best is to have the client
send it's own task_self() to the kernel server, then get the pointer
to kernel structures and deference them task->u_address->uu_cred.
I forget how one goes about turning ports into actual kernel structure pointers
but it is/should be possible (can't remember if I ever got it working)

>	* It doesn't seem like it will buy me anything.  I was excited
>	at the prospect of using out-of-line data to move moderately size
>	hunks of data between the kernel driver and user code using
>	the fancy Mach copy-on-write VM.  But it seems that since the
>	loadable kernel servers don't allow this to work, and I have to
>	copy the data anyway.

out-of-line data is only real efficient when your passing page aligned
page sized data, anything else turns into a copy of sorts anyways. If your
data blocks are under half a page size or so, then copy is fine.
But as you say, this is broken in 2.0, there was another poster who
had this problem and said it was fixed in 3.0, but that hasn't materialized
yet.

I personally prefer the Mach interface because you don't have to worry
about your server/handler getting reentered, everything is single threaded
off the queue of messages (unless you add more threads yourself) so
there is less locking/sleep paranoia type things.  I also like the
flexibilty of being able to design whatever kind of interface I see fit, not
tied to read/write/ioctl for ALL purposes.

<shrug> all depends on your needs.

la la la,
-- 
:: Christopher Lloyd :: a74k110@titan.ucc.umass.edu :: Yrrid, Inc. ::
Technical Details
Message-ID: <1992Aug14.203248.3710@nic.umass.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!nic.umass.edu!titan.ucc.umass.edu!a74k110
References: <1992Aug14.133748.29123@ni.umd.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!nic.umass.edu!titan.ucc.umass.edu!a74k110
From: a74k110@titan.ucc.umass.edu (Chris Lloyd)
Subject: Re: Mach messaging to kernel server vs. "traditional" kernel drivers
Message-ID: <1992Aug14.203248.3710@nic.umass.edu>
Sender: usenet@nic.umass.edu (USENET News System)
Nntp-Posting-Host: titan.ucc.umass.edu
Organization: University of Massachusetts, Amherst
References: <1992Aug14.133748.29123@ni.umd.edu>
Date: Fri, 14 Aug 1992 20:32:48 GMT
Lines: 53