From: Don Raikes <don.raikes@oracle.com>
To: "Speakup is a screen review system for Linux."
<speakup@linux-speakup.org>
Subject: RE: ot memory allocation question
Date: Fri, 19 Jul 2013 08:47:38 -0700 (PDT) [thread overview]
Message-ID: <be7e1100-7095-4f86-a53e-fbbc68886c28@default> (raw)
In-Reply-To: <87fvvawwrj.fsf@mushroom.PK5001Z>
Chris,
Could I do something like:
Mm_segment_t cur_fs = get_fs();
Set_fs(get_ds()); // which puts me in userspace
Char * newbuf[required_size];
Set_fs(cur_fs);
If (copy_to_user(newbuf,srcbuf,required_size);
Ret = sys_write_orig(fd, newbuf,required_size);
-----Original Message-----
From: Chris Brannon [mailto:chris@the-brannons.com]
Sent: Friday, July 19, 2013 5:38 AM
To: Speakup is a screen review system for Linux.
Subject: Re: ot memory allocation question
Don Raikes <don.raikes@oracle.com> writes:
> 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?
There's no easy way to do this. You can't just pass your kernel buffer to the system call you are intercepting, since the intercepted call expects a user-space buffer.
Have a look at this link for some inspiration:
http://web.cs.wpi.edu/~cs4513/b05/proj1note2.txt
Also be careful about the return value of the real sys_write system call. If you're passing it a buffer larger than the n bytes passed in from userspace, its return value can be greater than n. Don't just use it unmodified as the return value for your function.
-- Chris
_______________________________________________
Speakup mailing list
Speakup@linux-speakup.org
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
next prev parent reply other threads:[~ UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
Don Raikes
` Chris Brannon
` covici
` Chris Brannon
` covici
` Brian Buhrow
` Don Raikes
` Don Raikes [this message]
` 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=be7e1100-7095-4f86-a53e-fbbc68886c28@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).