Re: [PATCH] fs/fuse: fix potential memory leak from fuse_uring_cancel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 9 Sept 2025 at 11:50, Jian Huang Li <ali@xxxxxxx> wrote:
>
> fuse: fix potential memory leak from fuse_uring_cancel
>
> If umount or fuse daemon quits at early stage, could happen all ring queues
> have already stopped and later some FUSE_IO_URING_CMD_REGISTER commands get
> canceled, that leaves ring entities in ent_in_userspace list and will not
> be freed by fuse_uring_destruct.
> Move such ring entities to ent_canceled list and ensure fuse_uring_destruct
> frees these ring entities.

Thank you for the report.

Do you have a reproducer?

> Fixes: b6236c8407cb ("fuse: {io-uring} Prevent mount point hang on
> fuse-server termination")
> Signed-off-by: Jian Huang Li <ali@xxxxxxx>
> ---
>   fs/fuse/dev_uring.c   | 13 +++++++++++--
>   fs/fuse/dev_uring_i.h |  6 ++++++
>   2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
> index 249b210becb1..db35797853c1 100644
> --- a/fs/fuse/dev_uring.c
> +++ b/fs/fuse/dev_uring.c
> @@ -203,6 +203,12 @@ void fuse_uring_destruct(struct fuse_conn *fc)
>                 WARN_ON(!list_empty(&queue->ent_commit_queue));
>                 WARN_ON(!list_empty(&queue->ent_in_userspace));
>
> +               list_for_each_entry_safe(ent, next, &queue->ent_canceled,
> +                                        list) {
> +                       list_del_init(&ent->list);
> +                       kfree(ent);
> +               }

Instead of introducing yet another list, we could do the same
iterate/free on the ent_in_userspace list?

Thanks,
Miklos




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux