[v2] mem: fix infinite loop
Checks
Commit Message
When the process address space is insufficient,
mmap will fail, which will cause an infinite loop.
This patch stops attempting mmap if it fails and
the requested size cannot be reduced.
Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
Cc: stable@dpdk.org
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
lib/eal/common/eal_common_memory.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
On 4/3/2025 4:57 AM, Dengdui Huang wrote:
> When the process address space is insufficient,
> mmap will fail, which will cause an infinite loop.
> This patch stops attempting mmap if it fails and
> the requested size cannot be reduced.
>
> Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
On Thu, Apr 3, 2025 at 4:57 AM Dengdui Huang <huangdengdui@huawei.com> wrote:
>
> When the process address space is insufficient,
> mmap will fail, which will cause an infinite loop.
> This patch stops attempting mmap if it fails and
> the requested size cannot be reduced.
>
> Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Applied, thanks.
@@ -101,8 +101,12 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
mapped_addr = eal_mem_reserve(
requested_addr, (size_t)map_sz, reserve_flags);
- if ((mapped_addr == NULL) && allow_shrink)
- *size -= page_sz;
+ if (mapped_addr == NULL) {
+ if (allow_shrink)
+ *size -= page_sz;
+ else
+ break;
+ }
if ((mapped_addr != NULL) && addr_is_hint &&
(mapped_addr != requested_addr)) {