Commit dc4e372f authored by Tahsin Erdogan's avatar Tahsin Erdogan Committed by Greg Kroah-Hartman

fuse: clear FR_PENDING flag when moving requests out of pending queue

commit a8a86d78 upstream.

fuse_abort_conn() moves requests from pending list to a temporary list
before canceling them. This operation races with request_wait_answer()
which also tries to remove the request after it gets a fatal signal. It
checks FR_PENDING flag to determine whether the request is still in the
pending list.

Make fuse_abort_conn() clear FR_PENDING flag so that request_wait_answer()
does not remove the request from temporary list.

This bug causes an Oops when trying to delete an already deleted list entry
in end_requests().

Fixes: ee314a87 ("fuse: abort: no fc->lock needed for request ending")
Signed-off-by: default avatarTahsin Erdogan <tahsin@google.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6f3002c2
...@@ -2083,7 +2083,6 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head) ...@@ -2083,7 +2083,6 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head)
struct fuse_req *req; struct fuse_req *req;
req = list_entry(head->next, struct fuse_req, list); req = list_entry(head->next, struct fuse_req, list);
req->out.h.error = -ECONNABORTED; req->out.h.error = -ECONNABORTED;
clear_bit(FR_PENDING, &req->flags);
clear_bit(FR_SENT, &req->flags); clear_bit(FR_SENT, &req->flags);
list_del_init(&req->list); list_del_init(&req->list);
request_end(fc, req); request_end(fc, req);
...@@ -2161,6 +2160,8 @@ void fuse_abort_conn(struct fuse_conn *fc) ...@@ -2161,6 +2160,8 @@ void fuse_abort_conn(struct fuse_conn *fc)
spin_lock(&fiq->waitq.lock); spin_lock(&fiq->waitq.lock);
fiq->connected = 0; fiq->connected = 0;
list_splice_init(&fiq->pending, &to_end2); list_splice_init(&fiq->pending, &to_end2);
list_for_each_entry(req, &to_end2, list)
clear_bit(FR_PENDING, &req->flags);
while (forget_pending(fiq)) while (forget_pending(fiq))
kfree(dequeue_forget(fiq, 1, NULL)); kfree(dequeue_forget(fiq, 1, NULL));
wake_up_all_locked(&fiq->waitq); wake_up_all_locked(&fiq->waitq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment