linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Sanket Rathi <sanket.rathi@cdac.ernet.in>
Cc: Ravi <kravi26@yahoo.com>, linux-mm@kvack.org
Subject: Re: Fwd: Re: How CPU(x86) resolve kernel address
Date: Tue, 9 Apr 2002 10:08:38 +0100	[thread overview]
Message-ID: <20020409100838.C2807@redhat.com> (raw)
In-Reply-To: <Pine.GSO.4.10.10204091052060.13298-100000@mailhub.cdac.ernet.in>; from sanket.rathi@cdac.ernet.in on Tue, Apr 09, 2002 at 10:59:12AM +0530

Hi,

On Tue, Apr 09, 2002 at 10:59:12AM +0530, Sanket Rathi wrote:

> but i tried. i allocate memory buffers in application and pass their
> address to driver. there i use the following 
> 
>  if (pgd_none(*(pgd = pgd_offset(current->mm,virtAddress))) ||
> 
>                 pmd_none(*(pmd = pmd_offset(pgd, virtAddress))) ||
> 
>                 pte_none(*(pte = pte_offset(pmd, virtAddress))) )
>                 {
>                         printk("\nphysical address failed\n") ;
>                         return (-1) ;
>                 }
>                 phyAddress = pte_page(*pte) ;
>                 printk("\nphysical address is %x",(unsigned
> long)phyAddress) ;

You cannot do that.  The physical memory used by the application can
get swapped out, and if you malloc() a page, all you get initially is
a copy-on-write instance of the zero page.  You *must* use something
like map_user_kiobuf() or the ptrace address-poking code to access the
user buffer safely.  Even safer is to allocate the buffer inside your
driver instead and then mmap that into user space.

Cheers,
 Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

  reply	other threads:[~2002-04-09  9:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020407025738.90777.qmail@web12307.mail.yahoo.com>
2002-04-09  5:29 ` Sanket Rathi
2002-04-09  9:08   ` Stephen C. Tweedie [this message]
2002-04-09 14:34   ` Martin J. Bligh

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=20020409100838.C2807@redhat.com \
    --to=sct@redhat.com \
    --cc=kravi26@yahoo.com \
    --cc=linux-mm@kvack.org \
    --cc=sanket.rathi@cdac.ernet.in \
    /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