lkml.org 
[lkml]   [2003]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: top stack (l)users for 2.5.69
Linus Torvalds wrote:
> In article <Pine.LNX.4.53.0305070933450.11740@chaos>,
> Richard B. Johnson <root@chaos.analogic.com> wrote:
>
>>You know (I hope) that allocating stuff on the stack is not
>>"bad".
>
>
> Allocating stuff on the stack _is_ bad if you allocate more than a few
> hundred bytes. That's _especially_ true deep down in the call-sequence,
> ie in device drivers, low-level filesystems etc.
>
> The kernel stack is a very limited resource, with no protection from
> overflow. Being lazy and using automatic variables is a BAD BAD thing,
> even if it's syntactically easy and generates good code.


Note that the problem is exacerbated if you have a bunch of disjoint
stack scopes. For that case, gcc will take the _sum_ of the stacks and
not the union. rth was kind enough to file gcc PR 9997 on this problem.

It is turning out to be fairly common problem in the various drivers'
ioctl handlers. Kernel hackers (myself included) often create automatic
variables for each case in a C switch statement. (and now I'm having to
go back and fix that :))

Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:35    [from the cache]
©2003-2011 Jasper Spaans