|
From: | Richard Henderson |
Subject: | Re: [PATCH] linux-user: ppoll: eliminate large alloca |
Date: | Fri, 16 Dec 2022 12:44:30 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 12/16/22 11:22, Michael Tokarev wrote:
do_ppoll() in linux-user/syscall.c uses alloca() to allocate an array of struct pullfds on the stack. The only upper boundary for number of entries for this array is so that whole thing fits in INT_MAX. But this is definitely too much for a stack allocation. Use heap allocation when large number of entries is requested (currently 128, arbitrary), and continue to use alloca() for smaller allocations, to optimize small operations for small sizes.
I think it would be cleaner to always use heap allocation, and use g_autofree for the pointer. r~
[Prev in Thread] | Current Thread | [Next in Thread] |