ot memory allocation question

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

 



Sorry folks, but I still have a question about all this kernel programming stuff.

 

Is it possible from within a kernel module to allocate memory in userspace?

 

The reason I am asking is the function I am hooking into sys_write takes a buffer as input, but the buffer is defined as const __user *.

 

To me this means that if I modify the text that I was given in the buffer and want it to get written to the file, then I need to update the buffer.

However since the buffer is a const, I shuldn't write to it, plus in my case I am enlarging the amount of data, so if I were to cast the buffer to a writable __user *, then I am in danger of overwriting something I shouldn't in the user process (which in my case is the file pointer).

 

After completing the sys_write by passing the updated buffer to the original sys_write, I try to close the file and get an error.

 

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?

-- 
Best Regards, Donald

HYPERLINK "http://www.oracle.com/"; \nOracle
Donald raikes | Accessibility Specialist/ QA Engineer
Phone: HYPERLINK "tel:+15202717608"+15202717608 | Mobile: HYPERLINK "tel:+15202717608"+15202717608 
Oracle Quality Assurance
| Tucson, Arizona 

HYPERLINK "http://www.oracle.com/commitment"; \nGreen Oracle

Oracle is committed to developing practices and products that help protect the environment

 


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