mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Oeser <ingo.oeser@informatik.tu-chemnitz.de>
To: Matt <madmatt@bits.bris.ac.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: ioctl arg passing
Date: Mon, 23 Apr 2001 19:50:43 +0200	[thread overview]
Message-ID: <20010423195043.S682@nightmaster.csn.tu-chemnitz.de> (raw)
In-Reply-To: <Pine.LNX.4.21.0104231648330.1089-100000@bits.bris.ac.uk>
In-Reply-To: <Pine.LNX.4.21.0104231648330.1089-100000@bits.bris.ac.uk>; from madmatt@bits.bris.ac.uk on Mon, Apr 23, 2001 at 05:06:48PM +0100

On Mon, Apr 23, 2001 at 05:06:48PM +0100, Matt wrote:
> I'm writing a char device driver for a dsp card that drives a motion
> platform.

Can you elaborate on the dsp card? Is it freely programmable? I'm
working on a project to support this kind of stuff via a
dedicated subsystem for Linux.

The problem is, that it's hard to get access to such cards. So
development is moving very slow :-(

> To pass the instructions I'm using a generic ioctl which passes the data
> between user & kernel-space using a struct which is basically like:
> 
> struct instruction_t {
> 	__s16 code;
> 	__s16 rxlen;
> 	__s16 *rxbuf;
> 	__s16 txlen;
> 	__s16 *txbuf;
> };
 
Such stuff is handled already by my subsystem. You just have to
provide some function to do some checks on memory buffers
(readable, writeable, executable, unreachable, properly aligned
and sized transfer unit and so on) and functions for transfers
(which can be sych/asych), ioctls and and debugging interface for
special purposes.

> (rx|tx)len is the length of the extra data that is provided/requested
> in/to be in (rx|tx)buf. Got me so far?
> 
> Am I allowed to do this across the ioctl interface? In my ioctl
> "handler" I'm attempting to do:
> 
> --8<--
> 
> struct instruction_t local;
> __s16 *temp;
> 
> copy_from_user( &local, ( struct instruction_t * ) arg, sizeof( struct instruction_t ) );
> temp = kmalloc( sizeof( __s16 ) * local.rxlen, GFP_KERNEL );
> copy_from_user( temp, arg, sizeof( __s16 ) * local.rxlen );
> local.rxbuf = temp;
> temp = kmalloc( sizeof( __s16 ) * local.txlen, GFP_KERNEL );
> ....
> 
> --8<--
> 
> Is this going to work as expected? Or am I gonna generate oops-a-plenty?

What do you want to do with the buffers? If you plan to expose
them to user space, this is just plain wrong.

If you use it only inside the kernel, please check that you avoid
using more than PAGE_SIZE as rxlen/txlen. Do scatter-gather
instead and vmalloc(). Either in the driver or by hardware
features.

Regards

Ingo Oeser
-- 
10.+11.03.2001 - 3. Chemnitzer LinuxTag <http://www.tu-chemnitz.de/linux/tag>
         <<<<<<<<<<<<     been there and had much fun   >>>>>>>>>>>>

  reply	other threads:[~2001-04-23 17:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-23 16:06 Matt
2001-04-23 17:50 ` Ingo Oeser [this message]
2001-04-23 20:14   ` Matt
2001-04-23 20:17   ` rui.sousa
2001-04-23 20:34     ` Matt
2001-04-23 20:37     ` Mathieu Chouquet-Stringer
2001-04-23 21:11       ` [OFFTOPIC] " rui.sousa
2001-04-23 19:58 ` Matt
2001-04-23 21:33   ` Ingo Oeser
2001-04-23 22:09 ` Matt
2001-04-23 23:41   ` Jonathan Lundell
2001-04-23 18:29 Petr Vandrovec
2001-04-23 16:40 ` Alex Bligh - linux-kernel

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=20010423195043.S682@nightmaster.csn.tu-chemnitz.de \
    --to=ingo.oeser@informatik.tu-chemnitz.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madmatt@bits.bris.ac.uk \
    /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

all inboxes | Powered by JetHome®