Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: lpfc: fix ndlp use-after-free in RLS accept callback
Date: Thu, 05 Nov 2026 16:02:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-199397@kernel.org> (raw)
In-Reply-To: <20261104025348.1527601-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] scsi: lpfc: inaccurate Fixes tag in commit message for lpfc_els_rsp_rls_acc()
--

commit 8109741dc29cffda7f87382c25b20f6a9dd30b92
Author: Wentao Liang <vulab@iscas.ac.cn>

scsi: lpfc: fix ndlp use-after-free in RLS accept callback

This commit fixes a use-after-free of ndlp in lpfc_els_rsp_rls_acc() by
delaying lpfc_nlp_put(ndlp) until after the IOCB reference on ndlp has
been acquired, and releasing it on earlier error paths.

>     scsi: lpfc: fix ndlp use-after-free in RLS accept callback
>     
>     lpfc_els_rcv_rls() takes a reference on the ndlp for the pending
>     MBX_READ_LNK_STAT command.  lpfc_els_rsp_rls_acc() drops that
>     reference right after building the ACC IOCB, but then keeps
>     dereferencing ndlp in the trace message and takes a fresh reference
>     for the IOCB.
>     
>     The node can be removed from the nodelist while the mailbox is
>     pending, so the put may be the last one and release ndlp through
>     lpfc_nlp_release().  The later ndlp->vport, ndlp->nlp_DID and
>     lpfc_nlp_get() calls then touch freed memory.
>     
>     Move the put after the reference for the IOCB has been acquired, and
>     release it on the paths that bail out before that point.
>     
>     Fixes: 12265f68ae92 ("[SCSI] lpfc 8.3.18: Add support of received ELS commands")
>     Cc: stable@vger.kernel.org
>     Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
>     Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

[Severity: Low]
In commit 12265f68ae92 ("[SCSI] lpfc 8.3.18: Add support of received ELS
commands"), lpfc_prep_els_iocb() itself acquired the IOCB reference on
ndlp via elsiocb->context1 = lpfc_nlp_get(ndlp) before returning elsiocb.
Calling lpfc_nlp_put(ndlp) right after lpfc_prep_els_iocb() in
lpfc_els_rsp_rls_acc() kept the IOCB's reference live when elsiocb was
non-NULL, and returned immediately without dereferencing ndlp when
elsiocb was NULL.

Commit 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference
taking") later removed lpfc_nlp_get(ndlp) from lpfc_prep_els_iocb() and
moved it to the end of lpfc_els_rsp_rls_acc(), while leaving the
lpfc_nlp_put(ndlp) call immediately after lpfc_prep_els_iocb().

Should the Fixes tag instead be:

  Fixes: 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104025348.1527601-1-vulab@iscas.ac.cn?part=1

      parent reply	other threads:[~2026-11-05 16:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  2:53 [PATCH] scsi: lpfc: fix ndlp use-after-free in RLS accept callback Wentao Liang
2026-11-04  7:10 ` Krzysztof Kozlowski
2026-11-05 16:02 ` sashiko-bot [this message]

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=sashiko-outbox-199397@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vulab@iscas.ac.cn \
    /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