ot memory allocation question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux