* [PATCH] fuse: check aborted connection before adding requests to pending list for resending
@ 2024-07-25 17:53 Joanne Koong
2024-07-26 14:45 ` Josef Bacik
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Joanne Koong @ 2024-07-25 17:53 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: winters.zc, josef, bs_lists, kernel-team
There is a race condition where inflight requests will not be aborted if
they are in the middle of being re-sent when the connection is aborted.
If fuse_resend has already moved all the requests in the fpq->processing
lists to its private queue ("to_queue") and then the connection starts
and finishes aborting, these requests will be added to the pending queue
and remain on it indefinitely.
Fixes: 760eac73f9f6 ("fuse: Introduce a new notification type for resend pending requests")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/dev.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 9eb191b5c4de..a11461ef6022 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -31,6 +31,8 @@ MODULE_ALIAS("devname:fuse");
static struct kmem_cache *fuse_req_cachep;
+static void end_requests(struct list_head *head);
+
static struct fuse_dev *fuse_get_dev(struct file *file)
{
/*
@@ -1820,6 +1822,13 @@ static void fuse_resend(struct fuse_conn *fc)
}
spin_lock(&fiq->lock);
+ if (!fiq->connected) {
+ spin_unlock(&fiq->lock);
+ list_for_each_entry(req, &to_queue, list)
+ clear_bit(FR_PENDING, &req->flags);
+ end_requests(&to_queue);
+ return;
+ }
/* iq and pq requests are both oldest to newest */
list_splice(&to_queue, &fiq->pending);
fiq->ops->wake_pending_and_unlock(fiq);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] fuse: check aborted connection before adding requests to pending list for resending
2024-07-25 17:53 [PATCH] fuse: check aborted connection before adding requests to pending list for resending Joanne Koong
@ 2024-07-26 14:45 ` Josef Bacik
2024-07-29 2:20 ` Jingbo Xu
2024-08-22 14:29 ` Miklos Szeredi
2 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2024-07-26 14:45 UTC (permalink / raw)
To: Joanne Koong; +Cc: miklos, linux-fsdevel, winters.zc, bs_lists, kernel-team
On Thu, Jul 25, 2024 at 10:53:34AM -0700, Joanne Koong wrote:
> There is a race condition where inflight requests will not be aborted if
> they are in the middle of being re-sent when the connection is aborted.
>
> If fuse_resend has already moved all the requests in the fpq->processing
> lists to its private queue ("to_queue") and then the connection starts
> and finishes aborting, these requests will be added to the pending queue
> and remain on it indefinitely.
>
> Fixes: 760eac73f9f6 ("fuse: Introduce a new notification type for resend pending requests")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Nice catch, you can add
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] fuse: check aborted connection before adding requests to pending list for resending
2024-07-25 17:53 [PATCH] fuse: check aborted connection before adding requests to pending list for resending Joanne Koong
2024-07-26 14:45 ` Josef Bacik
@ 2024-07-29 2:20 ` Jingbo Xu
2024-08-22 14:29 ` Miklos Szeredi
2 siblings, 0 replies; 4+ messages in thread
From: Jingbo Xu @ 2024-07-29 2:20 UTC (permalink / raw)
To: Joanne Koong, miklos, linux-fsdevel
Cc: winters.zc, josef, bs_lists, kernel-team
On 7/26/24 1:53 AM, Joanne Koong wrote:
> There is a race condition where inflight requests will not be aborted if
> they are in the middle of being re-sent when the connection is aborted.
>
> If fuse_resend has already moved all the requests in the fpq->processing
> lists to its private queue ("to_queue") and then the connection starts
> and finishes aborting, these requests will be added to the pending queue
> and remain on it indefinitely.
>
> Fixes: 760eac73f9f6 ("fuse: Introduce a new notification type for resend pending requests")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> fs/fuse/dev.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 9eb191b5c4de..a11461ef6022 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -31,6 +31,8 @@ MODULE_ALIAS("devname:fuse");
>
> static struct kmem_cache *fuse_req_cachep;
>
> +static void end_requests(struct list_head *head);
> +
> static struct fuse_dev *fuse_get_dev(struct file *file)
> {
> /*
> @@ -1820,6 +1822,13 @@ static void fuse_resend(struct fuse_conn *fc)
> }
>
> spin_lock(&fiq->lock);
> + if (!fiq->connected) {
> + spin_unlock(&fiq->lock);
> + list_for_each_entry(req, &to_queue, list)
> + clear_bit(FR_PENDING, &req->flags);
> + end_requests(&to_queue);
> + return;
> + }
> /* iq and pq requests are both oldest to newest */
> list_splice(&to_queue, &fiq->pending);
> fiq->ops->wake_pending_and_unlock(fiq);
LGTM.
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] fuse: check aborted connection before adding requests to pending list for resending
2024-07-25 17:53 [PATCH] fuse: check aborted connection before adding requests to pending list for resending Joanne Koong
2024-07-26 14:45 ` Josef Bacik
2024-07-29 2:20 ` Jingbo Xu
@ 2024-08-22 14:29 ` Miklos Szeredi
2 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2024-08-22 14:29 UTC (permalink / raw)
To: Joanne Koong; +Cc: linux-fsdevel, winters.zc, josef, bs_lists, kernel-team
On Thu, 25 Jul 2024 at 19:53, Joanne Koong <joannelkoong@gmail.com> wrote:
>
> There is a race condition where inflight requests will not be aborted if
> they are in the middle of being re-sent when the connection is aborted.
>
> If fuse_resend has already moved all the requests in the fpq->processing
> lists to its private queue ("to_queue") and then the connection starts
> and finishes aborting, these requests will be added to the pending queue
> and remain on it indefinitely.
>
> Fixes: 760eac73f9f6 ("fuse: Introduce a new notification type for resend pending requests")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Applied, thanks.
Miklos
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-22 14:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-25 17:53 [PATCH] fuse: check aborted connection before adding requests to pending list for resending Joanne Koong
2024-07-26 14:45 ` Josef Bacik
2024-07-29 2:20 ` Jingbo Xu
2024-08-22 14:29 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).