public inbox for speakup@linux-speakup.org
 help / color / mirror / Atom feed
From: Don Raikes <don.raikes@oracle.com>
To: "Speakup is a screen review system for Linux."
	<speakup@linux-speakup.org>
Subject: ot memory allocation question
Date: Fri, 19 Jul 2013 02:53:23 -0700 (PDT)	[thread overview]
Message-ID: <41356f9b-e7c3-4522-b960-142abea1cedd@default> (raw)

Sorry folks, but I still have a question about all this kernel programming stuff.

 

Is it possible from within a kernel module to allocate memory in userspace?

 

The reason I am asking is the function I am hooking into sys_write takes a buffer as input, but the buffer is defined as const __user *.

 

To me this means that if I modify the text that I was given in the buffer and want it to get written to the file, then I need to update the buffer.

However since the buffer is a const, I shuldn't write to it, plus in my case I am enlarging the amount of data, so if I were to cast the buffer to a writable __user *, then I am in danger of overwriting something I shouldn't in the user process (which in my case is the file pointer).

 

After completing the sys_write by passing the updated buffer to the original sys_write, I try to close the file and get an error.

 

My solution:

Allocate a new larger buffer inside of the userspace and copy_to_user into the new buffer and then when I pass control to the "real" sys_write function point it to the new buffer.

 

But the problem is how do I allocate this new buffer?

-- 
Best Regards, Donald

HYPERLINK "http://www.oracle.com/" \nOracle
Donald raikes | Accessibility Specialist/ QA Engineer
Phone: HYPERLINK "tel:+15202717608"+15202717608 | Mobile: HYPERLINK "tel:+15202717608"+15202717608 
Oracle Quality Assurance
| Tucson, Arizona 

HYPERLINK "http://www.oracle.com/commitment" \nGreen Oracle

Oracle is committed to developing practices and products that help protect the environment

 

             reply	other threads:[~ UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
 Don Raikes [this message]
 ` Chris Brannon
   ` covici
     ` Chris Brannon
       ` covici
         ` Brian Buhrow
       ` Don Raikes
   ` Don Raikes
   ` Don Raikes
     ` Chris Brannon
       ` Don Raikes
     ` Jason White

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=41356f9b-e7c3-4522-b960-142abea1cedd@default \
    --to=don.raikes@oracle.com \
    --cc=speakup@linux-speakup.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).