From: Hannes Reinecke <hare@suse.de>
To: Jianglei Nie <niejianglei2021@163.com>,
jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: libfc: Fix use after free in fc_exch_abts_resp()
Date: Thu, 3 Mar 2022 08:26:03 +0100 [thread overview]
Message-ID: <51943e86-e05c-8f3c-59de-e75af03a1efe@suse.de> (raw)
In-Reply-To: <20220303015115.459778-1-niejianglei2021@163.com>
On 3/3/22 02:51, Jianglei Nie wrote:
> fc_exch_release(ep) will decrease the ep's reference count. When the
> reference count reaches zero, it is freed. But ep is still used in the
> following code, which will lead to a use after free.
>
> We should return the function after the call of fc_exch_release() to
> avoid use after free.
>
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> ---
> drivers/scsi/libfc/fc_exch.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
> index 841000445b9a..aa223db4cf53 100644
> --- a/drivers/scsi/libfc/fc_exch.c
> +++ b/drivers/scsi/libfc/fc_exch.c
> @@ -1701,6 +1701,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
> if (cancel_delayed_work_sync(&ep->timeout_work)) {
> FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n");
> fc_exch_release(ep); /* release from pending timer hold */
> + return;
> }
>
> spin_lock_bh(&ep->ex_lock);
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
next prev parent reply other threads:[~2022-03-03 7:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 1:51 [PATCH] scsi: libfc: Fix use after free in fc_exch_abts_resp() Jianglei Nie
2022-03-03 7:26 ` Hannes Reinecke [this message]
2022-03-09 3:33 ` Martin K. Petersen
2022-03-15 5:02 ` Martin K. Petersen
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=51943e86-e05c-8f3c-59de-e75af03a1efe@suse.de \
--to=hare@suse.de \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=niejianglei2021@163.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