Re: How big can an array be on a kernel stack?

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

 



On Wed, Sep 4, 2024 at 3:26 AM Jeff Layton <jlayton@xxxxxxxxxx> wrote:
>
> On Tue, 2024-09-03 at 13:32 -0700, Rick Macklem wrote:
> > Hi,
> >
> > Subject line says it all. As a newbie to the Linux
> > kernel, I am wondering if an array of 70 pointers
> > is too big for the kernel stack?
> > (I assumed it is and kmalloc_array()d it, but thought
> > I'd check.)
> >
> > Thanks for any comments, rick
> >
>
> In the old days, we had 4k stacks and it was quite easy to blow it out
> putting big stuff there. These days, stacks are 16k (on most arches) so
> you're probably fine with a 560 byte array there in most cases.
>
> Still, with something that large, I usually do a kmalloc, just to be
> sure.
Yea, I was thinking the same thing. And then I came across this comment
in the NFSv3 acl code...
/* Avoid the use of posix_acl_alloc().  nfsacl_encode() is
* invoked in contexts where a memory allocation failure is
* fatal.  Fortunately this fake ACL is small enough to
* construct on the stack. */

So, now I have the array on the stack and it seems to work.
(Mind you, I am testing on 32bit, so I'm not sure what will happen for
others. Yea, believe it or not, my only Linux box is i686.;-(

Thanks for the help, rick

> --
> Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux