Re: Kernel Panic while trying to access the datastructure parameter in ioctl call.
Re: Kernel Panic while trying to access the datastructure parameter in ioctl call.
- Subject: Re: Kernel Panic while trying to access the datastructure parameter in ioctl call.
- From: Terry Lambert <email@hidden>
- Date: Thu, 19 Jul 2007 15:45:48 -0700
On Jul 19, 2007, at 12:18 PM, JanakiRam wrote:
4) The most likely cause is that your length is bogus; I notice that
your buffer "data" (which should not be a stack buffer, it should be
allocated!) is 2K in size, but you don't do anything to ensure that
your count "bytes" is > 0 and less than 2K, so you could easily be
overflowing the buffer. Another possibility is that, since 2K is a
heck of a lot of data in kernel terms (1/8th of your entire available
stack!!!), you could be trashing the kernel stack, resulting in the
panic (this is less likely than simply having a bogus length and
smashing your own stack, but it's a possibility).
Is this a restriction that we can't send the data more
than 2k from user space to kernel space ? . If we need to send more
data from user space to general kext , pls suggest ways to do it.
No, this is because you are using a stack buffer instead of an
allocated buffer. Auto variables are allocated on the stack (this is
part of the ISO/ANSI C standard).
If you want a large data area, and want to avoid the risk, allocate
the memory instead of declaring it to be on the stack (i.e. declare a
pointer, allocate the memory, copy into the allocated memory, free the
memory when you're done using it).
Even after putting the > 0 && < 2k cindition , its
still reproducing.
Then it's probably a stack smasher.
5) Finally, if you are using a worker thread to do the work instead
of doing it in the context of the process making the call (you should
know whether or not you are using one - in fact, you should have told
us this when you asked the question...), then it's trying to copy in
from kernel_process, which is the wrong process to copy in from.
Basically, all copies in or out MUST occur in the context of the
process requesting the copy.
I've a user space daemon process which gets created from
the main program using pthreads. From User space daemon process i'm
calling the ioctl to kernel extension. Do you mean this way of doing
it is not the proper way ?
If you start a worker thread in the kernel specifically associated
with your device driver, then you will not be able to copy in from
user space to the kernel. It doesn't sound like you are doing this.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden