ot memory allocation question
Don Raikes
don.raikes at oracle.com
Fri Jul 19 11:47:38 EDT 2013
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 at 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 at 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 at linux-speakup.org
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
More information about the Speakup
mailing list