From: Don Raikes <don.raikes@oracle.com>
To: "Speakup is a screen review system for Linux."
<speakup@linux-speakup.org>
Subject: RE: OT: kernel oops
Date: Thu, 18 Jul 2013 22:33:48 -0700 (PDT) [thread overview]
Message-ID: <8d1e7965-5bfe-4739-97a9-f483a615ca23@default> (raw)
In-Reply-To: <20130719013418.GA8869@jdc.jasonjgw.net>
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@jasonjgw.net]
Sent: Thursday, July 18, 2013 6:34 PM
To: speakup@linux-speakup.org
Subject: Re: OT: kernel oops
Don Raikes <don.raikes@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@linux-speakup.org
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
next prev parent reply other threads:[~ UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
Don Raikes
` Jason White
` Chris Brannon
` Don Raikes
` Don Raikes
` Jason White
` Don Raikes
` Jason White
` Don Raikes [this message]
` Jason White
` Don Raikes
` Jason White
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d1e7965-5bfe-4739-97a9-f483a615ca23@default \
--to=don.raikes@oracle.com \
--cc=speakup@linux-speakup.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).