kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Sadanand Warrier <sadanandwarrier@gmail.com>
Cc: Kernelnewbies@kernelnewbies.org
Subject: Re: get_user_pages and pinning
Date: Sat, 2 Jan 2021 14:20:09 +0100	[thread overview]
Message-ID: <X/BzCVpyiahjdFrM@kroah.com> (raw)
In-Reply-To: <CADJuq2zgG0FRYpNdFknoCBYAu-=ZG1XqdqW=Zkjp_cP8Tn01Ww@mail.gmail.com>

On Sat, Jan 02, 2021 at 07:39:08AM -0500, Sadanand Warrier wrote:
> Folks
>    Since Linux uses lazy evaluation with respect to allocating memory
> what happens if a user process allocates memory using malloc in excess
> of say 8 or nine pages and calls a device ioctl and passes the user
> space pointer to it to be used to pin pages using get_user_pages().
> This buffer is to be used for a dma read from a device.
> What happens if the memory isn't actually allocated (no initialization
> with memset or calloc etc. and all PTEs are pointing to some zero
> filled page) and there is no IOMMU?

You should get an error of -EFAULT when you try to do this when the
kernel tries to access memory you don't have.

But the best way to be sure is to actually try it yourself and see!
There's nothing preventing you from doing that, right?  :)

good luck!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2021-01-02 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 12:39 get_user_pages and pinning Sadanand Warrier
2021-01-02 13:08 ` Cengiz Can
2021-01-03 17:54   ` Sadanand Warrier
2021-01-03 18:26     ` Rik van Riel
2021-01-03 18:54       ` Sadanand Warrier
2021-01-02 13:20 ` Greg KH [this message]
2021-01-02 15:11   ` Sadanand Warrier
2021-01-03 17:58 Sadanand Warrier

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=X/BzCVpyiahjdFrM@kroah.com \
    --to=greg@kroah.com \
    --cc=Kernelnewbies@kernelnewbies.org \
    --cc=sadanandwarrier@gmail.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).