From: Pavel Shilovsky <piastryyy@gmail.com>
To: Ronnie Sahlberg <lsahlber@redhat.com>
Cc: linux-cifs <linux-cifs@vger.kernel.org>
Subject: Re: [PATCH] cifs: fix race between compound_send_recv() and the demultiplex thread
Date: Fri, 15 Nov 2019 10:07:05 -0800 [thread overview]
Message-ID: <CAKywueRUUfLcRMze1P5pgF8KPcizYdhFH_TBbBAZGr0fZa1ikw@mail.gmail.com> (raw)
In-Reply-To: <20191114061646.22122-2-lsahlber@redhat.com>
ср, 13 нояб. 2019 г. в 22:17, Ronnie Sahlberg <lsahlber@redhat.com>:
>
> There is a race where the open() may be interrupted between when we receive the reply
> but before we have invoked the callback in which case we never end up calling
> handle_cancelled_mid() and thus leak an open handle on the server.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
> fs/cifs/connect.c | 1 -
> fs/cifs/transport.c | 2 +-
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index ccaa8bad336f..802604a7e692 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -1223,7 +1223,6 @@ cifs_demultiplex_thread(void *p)
> if (mids[i] != NULL) {
> mids[i]->resp_buf_size = server->pdu_size;
> if ((mids[i]->mid_flags & MID_WAIT_CANCELLED) &&
> - mids[i]->mid_state == MID_RESPONSE_RECEIVED &&
> server->ops->handle_cancelled_mid)
> server->ops->handle_cancelled_mid(
> mids[i]->resp_buf,
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index ca3de62688d6..0f219f7653f3 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -1119,7 +1119,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
> midQ[i]->mid, le16_to_cpu(midQ[i]->command));
> send_cancel(server, &rqst[i], midQ[i]);
> spin_lock(&GlobalMid_Lock);
> - if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED) {
> + if (is_interrupt_error(rc)) {
> midQ[i]->mid_flags |= MID_WAIT_CANCELLED;
> midQ[i]->callback = cifs_cancelled_callback;
> cancelled_mid[i] = true;
> --
> 2.13.6
>
It doesn't seem that RC may be anything other than -ERESTARTSYS but
is_interrupt_error() should work.
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
--
Best regards,
Pavel Shilovsky
next prev parent reply other threads:[~2019-11-15 18:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 6:16 [PATCH 0/1] cifs: fix race between compound_send_recv() and the Ronnie Sahlberg
2019-11-14 6:16 ` [PATCH] cifs: fix race between compound_send_recv() and the demultiplex thread Ronnie Sahlberg
2019-11-15 18:07 ` Pavel Shilovsky [this message]
2019-11-20 23:57 ` Pavel Shilovsky
2019-11-21 0:09 ` Steve French
2019-11-21 19:34 ` Pavel Shilovsky
2019-11-14 18:40 ` [PATCH 0/1] cifs: fix race between compound_send_recv() and the Steve French
-- strict thread matches above, loose matches on Subject: below --
2019-11-14 1:42 [PATCH 0/1] cifs: fix race between compound_send_recv() and the demultiplex thread Ronnie Sahlberg
2019-11-14 1:42 ` [PATCH] " Ronnie Sahlberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKywueRUUfLcRMze1P5pgF8KPcizYdhFH_TBbBAZGr0fZa1ikw@mail.gmail.com \
--to=piastryyy@gmail.com \
--cc=linux-cifs@vger.kernel.org \
--cc=lsahlber@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).