ot memory allocation question

Don Raikes don.raikes at oracle.com
Fri Jul 19 12:00:18 EDT 2013


Chris,

I gave that code segmentthat I sent a try, and it gives me an error in the copy_to_user call.  It looks like none of the bytes were copied to the userspace buffer.
I also get incompatible pointer types in the call to sys_write
-----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