public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Scotty Bauer <sbauer@eng.utah.edu>
To: linux-kernel@vger.kernel.org
Subject: Accessing user-land memory without safe functions
Date: Thu, 3 Dec 2015 13:54:30 -0700	[thread overview]
Message-ID: <5660AC06.8080300@eng.utah.edu> (raw)

I Have been auditing a few drivers and have found some of them are
accessing user-land memory without either mapping the pages in, or
copying the data via the safe user access apis. 

The thing I have mostly been seeing is something along the lines of:

ioctl(etc, etc, arg) {

char buf[32];
__user *some_struct  = (type cast) arg;
 
size_t amount = some_struct->amount;

** do size check on amount **

copy_from_user(buf, some_struct->some_uland_addr, amount);

}


Above you see 2 unsafe user-land dereferences, the
some_struct->amount and some_struct->some_uland_addr.


Since I've seen this a couple times now I'm wondering if my
understanding of touching user-land memory is flawed.

For the above example Ioctl, the proper way to get access to those fields
through the safe copy_from_user or get_user() functions, correct?

I'm wondering if I should submit patches to fix the issues I've found,
but now I'm doubting whether they're really issues at all.

Thanks,
Scotty

             reply	other threads:[~2015-12-03 20:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 20:54 Scotty Bauer [this message]
2015-12-04  0:12 ` Accessing user-land memory without safe functions Jonathan Corbet
2015-12-04  0:32   ` Scotty Bauer

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=5660AC06.8080300@eng.utah.edu \
    --to=sbauer@eng.utah.edu \
    --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