[Devel] [PATCH hci-8.2] fs/pipe: use kvfree() for the buffer arrays of a resized pipe
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Tue Dec 1 15:44:42 MSK 2026
> Since commit c14599b9e5f7 ("fs/pipe: Use kvcalloc for pipe buffers")
> the buffer array of a pipe comes from kvcalloc(), but
> pipe_resize_ring() still frees it in two wrong ways.
>
> When the pipe holds more data than the new size, the EBUSY path frees
> the new array with kfree(). For a large pipe the array comes from
> vmalloc(), and kfree() of a vmalloc address crashes the node. Host root
> hits it with a filled 1 GiB pipe shrunk to 512 MiB:
>
> BUG: unable to handle page fault for address: ffffeb0200088008
> RIP: 0010:kfree+0x83/0x460
> pipe_resize_ring+0x546/0x5d0
> pipe_fcntl+0x2da/0x500
> do_fcntl+0x236/0x1560
>
> On success the old array is freed with kvfree() under
> pipe->rd_wait.lock with interrupts off, and vfree() can sleep:
>
> BUG: sleeping function called from invalid context at mm/vmalloc.c
>
> Use kvfree() on the EBUSY path, and free the old array after the
> unlock.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-158055
>
> Feature: mm: avoid high order allocations in all subsystems
> Fixes: c14599b9e5f7 ("fs/pipe: Use kvcalloc for pipe buffers")
> Reported-by: Artem Bulgakov <artem.bulgakov at virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply at sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261201-pipe-resize-kvfree-v1-1-0a27f34709e0@virtuozzo.com?part=1
More information about the Devel
mailing list