Re: alloca() in kernel code

2019-10-12 Thread Johnny Billquist
On 2019-10-13 01:18, Joerg Sonnenberger wrote: On Sun, Oct 13, 2019 at 12:46:24AM +0200, Johnny Billquist wrote: But if you use alloca(), you will have to check what size you'd like to allocate, and not allocate more than some maximum amount, I would assume. Or do you really think that it is ok

Re: alloca() in kernel code

2019-10-12 Thread Joerg Sonnenberger
On Sun, Oct 13, 2019 at 12:46:24AM +0200, Johnny Billquist wrote: > On 2019-10-12 20:47, Joerg Sonnenberger wrote: > > On Sat, Oct 12, 2019 at 08:13:25PM +0200, Johnny Billquist wrote: > > > On 2019-10-12 19:01, Emmanuel Dreyfus wrote: > > > > Mouse wrote: > > > > > > > > > I'm presumably

Re: alloca() in kernel code

2019-10-12 Thread Michael van Elst
jo...@bec.de (Joerg Sonnenberger) writes: >> Even if it comes from the bootloader, why would you want to use alloca()? >Because as Emmanuel wrote initially, dynamic allocations might not be >possible yet. More so than dynamic stack expansion. -- -- Michael van

Re: alloca() in kernel code

2019-10-12 Thread Johnny Billquist
On 2019-10-12 20:47, Joerg Sonnenberger wrote: On Sat, Oct 12, 2019 at 08:13:25PM +0200, Johnny Billquist wrote: On 2019-10-12 19:01, Emmanuel Dreyfus wrote: Mouse wrote: I'm presumably missing something here, but what? I suspect Maxime's concern is about uncontrolled stack-based variable

Re: alloca() in kernel code

2019-10-12 Thread Joerg Sonnenberger
On Sat, Oct 12, 2019 at 02:01:16AM +0200, Emmanuel Dreyfus wrote: > I recently encountered a situation where I had to deal with variable > length structure at a time where kernel dynamic allocator was not > initialized. You can borrow pages directly if the data is potentially larger. Joerg

Re: alloca() in kernel code

2019-10-12 Thread Joerg Sonnenberger
On Sat, Oct 12, 2019 at 08:13:25PM +0200, Johnny Billquist wrote: > On 2019-10-12 19:01, Emmanuel Dreyfus wrote: > > Mouse wrote: > > > > > I'm presumably missing something here, but what? > > > > I suspect Maxime's concern is about uncontrolled stack-based variable > > buffer, which could be

Re: alloca() in kernel code

2019-10-12 Thread Johnny Billquist
On 2019-10-12 19:01, Emmanuel Dreyfus wrote: Mouse wrote: I'm presumably missing something here, but what? I suspect Maxime's concern is about uncontrolled stack-based variable buffer, which could be used to crash the kernel. But in my case, the data is coming from the bootloader. I cannot

Re: alloca() in kernel code

2019-10-12 Thread Emmanuel Dreyfus
Mouse wrote: > I'm presumably missing something here, but what? I suspect Maxime's concern is about uncontrolled stack-based variable buffer, which could be used to crash the kernel. But in my case, the data is coming from the bootloader. I cannot think about a scenario where it makes sense to

Re: alloca() in kernel code

2019-10-12 Thread Mouse
>> [...alloca() in kernel code...] > The kernel stack is rather small, we should not start allocating > variable-sized stuff on it. You say that as though the part after the comma follows from the part before it. If so, I don't understand why. The alternative seems to me to be to allocate a