Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021 at 9:59 AM Peter Maydell wrote: > On Thu, 6 May 2021 at 15:57, Warner Losh wrote: > > malloc, on the other hand, involves taking out a number of mutexes > > and similar things to obtain the memory, which may not necessarily > > be safe in all the contexts system calls can be

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021 at 10:04 AM Peter Maydell wrote: > On Thu, 6 May 2021 at 16:46, Eric Blake wrote: > > > > On 5/6/21 10:30 AM, Warner Losh wrote: > > > > > > > > But for the real answer, I need to contact the original authors of > > > this part of the code (they are no longer involved

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Peter Maydell
On Thu, 6 May 2021 at 16:46, Eric Blake wrote: > > On 5/6/21 10:30 AM, Warner Losh wrote: > > > > > But for the real answer, I need to contact the original authors of > > this part of the code (they are no longer involved day-to-day in > > the bsd-user efforts) to see if this scenario is possible

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Peter Maydell
On Thu, 6 May 2021 at 15:57, Warner Losh wrote: > malloc, on the other hand, involves taking out a number of mutexes > and similar things to obtain the memory, which may not necessarily > be safe in all the contexts system calls can be called from. System > calls are, typically, async safe and

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Eric Blake
On 5/6/21 10:30 AM, Warner Losh wrote: > > But for the real answer, I need to contact the original authors of > this part of the code (they are no longer involved day-to-day in > the bsd-user efforts) to see if this scenario is possible or not. If > it's easy to find out that way, we can either

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021 at 9:12 AM Eric Blake wrote: > On 5/6/21 9:55 AM, Warner Losh wrote: > > >>> Where is this freed? Also, alloca just moves a stack pointer, where > >> malloc > >>> has complex interactions. Are you sure that's a safe change here? > >> > >> It's freed any time the g_autofree

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Eric Blake
On 5/6/21 9:55 AM, Warner Losh wrote: >>> Where is this freed? Also, alloca just moves a stack pointer, where >> malloc >>> has complex interactions. Are you sure that's a safe change here? >> >> It's freed any time the g_autofree variable goes out of scope (that's >> what the g_autofree macro is

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021 at 8:57 AM Philippe Mathieu-Daudé wrote: > On 5/6/21 4:48 PM, Warner Losh wrote: > > > > > > On Thu, May 6, 2021 at 8:21 AM Peter Maydell > > wrote: > > > > On Thu, 6 May 2021 at 15:17, Warner Losh > > wrote:

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Philippe Mathieu-Daudé
On 5/6/21 4:48 PM, Warner Losh wrote: > > > On Thu, May 6, 2021 at 8:21 AM Peter Maydell > wrote: > > On Thu, 6 May 2021 at 15:17, Warner Losh > wrote: > > > > > > > > On Thu, May 6, 2021, 7:38 AM Philippe

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021 at 8:26 AM Eric Blake wrote: > On 5/6/21 9:16 AM, Warner Losh wrote: > > On Thu, May 6, 2021, 7:38 AM Philippe Mathieu-Daudé > > wrote: > > > >> The ALLOCA(3) man-page mentions its "use is discouraged". > >> > >> Replace it by a g_new() call. > >> > >> Signed-off-by:

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021 at 8:21 AM Peter Maydell wrote: > On Thu, 6 May 2021 at 15:17, Warner Losh wrote: > > > > > > > > On Thu, May 6, 2021, 7:38 AM Philippe Mathieu-Daudé > wrote: > >> > >> The ALLOCA(3) man-page mentions its "use is discouraged". > >> > >> Replace it by a g_new() call. > >> >

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Eric Blake
On 5/6/21 9:16 AM, Warner Losh wrote: > On Thu, May 6, 2021, 7:38 AM Philippe Mathieu-Daudé > wrote: > >> The ALLOCA(3) man-page mentions its "use is discouraged". >> >> Replace it by a g_new() call. >> >> Signed-off-by: Philippe Mathieu-Daudé >> --- >> bsd-user/syscall.c | 3 +-- >> 1 file

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Peter Maydell
On Thu, 6 May 2021 at 15:17, Warner Losh wrote: > > > > On Thu, May 6, 2021, 7:38 AM Philippe Mathieu-Daudé wrote: >> >> The ALLOCA(3) man-page mentions its "use is discouraged". >> >> Replace it by a g_new() call. >> >> Signed-off-by: Philippe Mathieu-Daudé >> --- >> bsd-user/syscall.c | 3

Re: [PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Warner Losh
On Thu, May 6, 2021, 7:38 AM Philippe Mathieu-Daudé wrote: > The ALLOCA(3) man-page mentions its "use is discouraged". > > Replace it by a g_new() call. > > Signed-off-by: Philippe Mathieu-Daudé > --- > bsd-user/syscall.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git

[PATCH v2 4/9] bsd-user/syscall: Replace alloca() by g_new()

2021-05-06 Thread Philippe Mathieu-Daudé
The ALLOCA(3) man-page mentions its "use is discouraged". Replace it by a g_new() call. Signed-off-by: Philippe Mathieu-Daudé --- bsd-user/syscall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 4abff796c76..dbee0385ceb