ot memory allocation question
Chris Brannon
chris at the-brannons.com
Fri Jul 19 08:37:52 EDT 2013
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
More information about the Speakup
mailing list