Re: 2.2.x: Secret stack size limit in Driver file-ops??? (Was:are Generic ioctls a good thing?)

From: Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Date: Sun Nov 05 2000 - 09:26:37 EST


On Sun, Nov 05, 2000 at 01:08:40PM +0100, Bernd Harries wrote:
> Is there a limit to the stack size (automatic variables) in
> driver methods, esp. ioctl?
 
Yes, there is. It's INIT_TASK_SIZE. See include/linux/sched.h for
this.

> I was just implementing some generic ioctls where the size field and cmd field
> are defined at runtime. For testing I use a kernbuf on the stack.

kmalloc() and kfree() it instead.

> In the Linux Device Drivers book I didn't find 'stack size' or
> similar in the index. Are there any limits on the stacksize? If
> yes, how large are they and why would the driver behave so
> stange and not oops or hang? I fear, my filesystem on the test
> Box could be damaged. I saw this bad addres error quite some
> times and suddenly make modules complained about strange
> contents in .config...

Because it's an overall kernel limit. Once you are in kernel
mode, you have less than the above amount of stack. So don't use
it for sth. more complex then pointers or ints. And avoid
recursion as hell.

The kernel will not oops, but instead overwriting your
current task_struct.

> Does gcc grow the stack only at the beginning of a function, or
> can it save the space and re-grow it on entering code_blocks
> also?
 
Check the assembler stage output ;-)

Regards

Ingo Oeser

-- 
Feel the power of the penguin - run linux@your.pc
<esc>:x
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Nov 07 2000 - 21:00:17 EST