mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <linux-os@analogic.com>
To: Matthew Dharm <mdharm-kernel@one-eyed-alien.net>
Cc: Kernel Developer List <linux-kernel@vger.kernel.org>
Subject: Re: mmap() and ioctl()
Date: Mon, 4 Apr 2005 15:02:26 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0504041453440.5597@chaos.analogic.com> (raw)
In-Reply-To: <20050404182749.GA6464@one-eyed-alien.net>

On Mon, 4 Apr 2005, Matthew Dharm wrote:

> This probably is a silly question, but....
>
> Is is possible to open a file, mmap() it into memory, then pass the address
> of that map via an ioctl() call to the kernel, which will copy_from_user()
> that data?
>

Yes. A user-mode pointer, passed via ioctl() is valid in the kernel
in the context of the user, i.e., during read() write() ioctl().

However, it is not valid if it is accessed by some other process or
an interrupt. In other words, you can't store it somewhere and
access it later in some other context.

> Yeah, that's an odd concept, I know... I could always malloc() some
> memory, read the file in, and then ioctl() it.  But, if I could get away
> with a direct mmap(), that would be much better for me.
>
> Matt
>

Since you need to copy anyway, you could mmap() your kernel
data (impliment mmap in your driver). Then you mmap both
"files" the same way and copy to/from in user-mode.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

  reply	other threads:[~2005-04-04 19:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-04 18:27 Matthew Dharm
2005-04-04 19:02 ` Richard B. Johnson [this message]
2005-04-04 19:19   ` Matthew Dharm
2005-04-05 15:30 Aleksey Gorelov

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.61.0504041453440.5597@chaos.analogic.com \
    --to=linux-os@analogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdharm-kernel@one-eyed-alien.net \
    /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®