public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <hancockr@shaw.ca>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: kernel mmap() and friends.
Date: Tue, 08 Mar 2005 19:45:35 -0600	[thread overview]
Message-ID: <422E553F.7040608@shaw.ca> (raw)

linux-os wrote:

 > If one uses x = __get_dma_pages(GFP_KERNEL, nr), finds the physical
 > address with b = virt_to_bus(x), then attempts to mmap(,,b,,,) the result
 > _does_not_fail_, yet the user ends up with memory ...somewhere....
 > that is R/W able and WRONG.


I don't think virt_to_bus is the correct function to be using for this 
translation (or pretty much anything, these days). What is this memory 
that you are attempting to do an mmap on, and where is this code going? 
Unless this is an ISA device and you need physical memory for DMA, 
__get_dma_pages is not correct either.

 >
 > Yet, if the code executes SetPageReserved(virt_to_page(x)), the
 > mmap() works and the user gets the CORRECT page(s).
 >
 > I think that if mmap() needs a physical buffer to be reserved
 > then that's fine. However, silently returning some different
 > buffer is a BUG.
 >
 > Is anyone aware of this BUG? Does anybody else care?


The kernel isn't responsible for checking that the memory ranges you 
attempt to remap are what you intended - if you get this wrong, things 
can blow up, that's just the way it is.

I would suggest following some similar driver/code in the kernel as an 
example if possible..

-- 
Robert Hancock      Saskatoon, SK, Canada
Home Page: http://www.roberthancock.com/




             reply	other threads:[~2005-03-09  1:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-09  1:45 Robert Hancock [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-03-08 19:04 kernel mmap() and friends linux-os

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=422E553F.7040608@shaw.ca \
    --to=hancockr@shaw.ca \
    --cc=linux-kernel@vger.kernel.org \
    /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