linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ahmed Masud <masud@marauder.googgun.com>
To: Xiaozhou Qiu <xzqiu@hotmail.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: how to communicate between kernel and user space?
Date: Fri, 30 Nov 2001 03:01:36 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.33.0111300240080.24257-100000@marauder.googgun.com> (raw)
In-Reply-To: <F56sjUHQHh2wLCVYl4m0000010f@hotmail.com>

On Thu, 29 Nov 2001, Xiaozhou Qiu wrote:

> Hi,
>
> I am sorry if this is a newbie's question. I am developing a kernel module
> which needs to call some crypt functions implemented in user space. Since
> those functions utilize openssl library, I assume there is no easy way to
> port them into kernel.
>

No there isn't really an easy way to put the entire OpenSSL library in the
kernel, and perhaps you don't want to do it on the outset.

The easiest (first draft) way to probably do it - not withstanding
operational constraints - is to create a pseduo character/block device -
write a userspace daemon for encryption / decryption - store the private
key in the kernel through /proc interface or an ioctl over the device.

And pass SSL requests and data back and forth using reads and writes over
the character/block device that you created.

If I understand the motivation correctly, you want some other parts of the
kernel to be able to use SSL .... The daemon pseudo code would be:

	struct {
		request_t 	req;
		params_t	parms;
	} request;

	sslfd = open ( "/dev/block" ) ;
	while(!eof()) {
		read(sslfd, &request, sizeof(request));
		switch(params.request) {
		OPEN_SSL_FUNCTION_1:
			openSSL_func1(params.data);
			full_up_return(retdata);
			write(&retdata);
			break;

		OPEN_SSL_FUNCTION_2:
			...
			break;

		default:
			invalid_request();
			break
		}
	}


> I wonder whether there is an easy and elegant way to call the user space
> functions from the kernel and get the results, if /proc can not be used.  If

The daemon would block until a request came through over the device.


> anybody knows where I can find a crypt library in the kernel, that will be a
> great help too.

Now ... ofcourse, and i haven't had much experience with this so perhaps
someone else can shed further light, the said daemon could eventually be
spawned by the kernel as a kernel thread ? I am a bit uncertain as to
whether this problem fits the kernel-thread paradigm.  Not sure.

You would have to worry about what happens if the daemon is NOT present in
a production environment?

Have a look at devfsd ... It's a very interesting tool that communicates
with the kernel and really provides services to the kernel rather than the
other way around.

---

On a grander note.. and this is simply an idea that's just sprung up so
please shoot it down if it's whacked - or perhaps not whacked :-).

Wouldn't it be cool to have a unified kernel interface to allow full blown
userspace progies that provided extended services to the kernel ( like the
open ssl example above ) - launched by the kernel as needed and providing
data back and forth using a more organized mechanism than ioctls?

Just a thought,

Ahmed.


      parent reply	other threads:[~2001-11-30  8:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-29 17:27 how to communicate between kernel and user space? Xiaozhou Qiu
2001-11-29 14:38 ` Leonardo C. Filho
2001-11-29 18:46 ` Andre Hedrick
2001-11-30  8:01 ` Ahmed Masud [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.33.0111300240080.24257-100000@marauder.googgun.com \
    --to=masud@marauder.googgun.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xzqiu@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).