OT: kernel oops

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

 



Ok so I get it, but the problem is that I am hooking into the sys_write systemcall, and it is by default cast to a const.

If I leave it as is, and cast the buf in my copy_to_user to a (char*) should that work?

Sorry my knowledge of c is very limited :)

It looks at the moment like when I do the sys_write function then try calling the sys_close that I have lost the pointer to my file.
Could I have messed up the stack yet again?
-----Original Message-----
From: Jason White [mailto:jason@xxxxxxxxxxxx] 
Sent: Thursday, July 18, 2013 6:34 PM
To: speakup at linux-speakup.org
Subject: Re: OT: kernel oops

Don Raikes <don.raikes at oracle.com> wrote:
 
> If (copy_to_user(buf, tbuf2, count))
> 
> Buf is defined in the parameter list of my function as:
> Const char __user * buf

It's also the destination of the copy, so it shouldn't be const. You're declaring the buffer as const, then passing it to a function that will write to it.

This is why the compiler complains that you're discarding the const qualifier when you pass this parameter to the function.

Does that help?

It's probably best to remove the "const" from the declaration of buf.
Alternatively, you can use a cast expression in the call to copy_to_user, but declaring a parameter as constant and then casting that away is not a good practice in my personal view.

_______________________________________________
Speakup mailing list
Speakup at linux-speakup.org
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup


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