Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v4 0/3] scsi: bfa: bound the unsolicited frame receive path
@ 2026-10-16  8:28 Yehyeong Lee
  2026-10-16  8:28 ` [PATCH v4 1/3] scsi: bfa: clamp the received unsolicited frame length to the buffer Yehyeong Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yehyeong Lee @ 2026-10-16  8:28 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, linux-kernel, yhlee

Three fixes in the bfa unsolicited frame receive path. Together they close
the length the path trusts, from where it enters to where it is used.

 1  uf_recv() takes the received length straight from the firmware's
    completion message and only warns if it is below sizeof(struct
    fchs_s). It is a 16-bit field and nothing caps it at the buffer that
    was posted, so every consumer below can be handed a length larger
    than the frame. The worst of them is bfa_fcs_lport_echo(), which uses
    it as a memcpy size into the fcxp request payload buffer, so that one
    is an out-of-bounds write and not just a read. Cap the length at the
    buffer that was posted.
 2  bfa_fcs_uf_recv() steps over a virtual fabric tagging header without
    checking that the frame is long enough to hold it. The length is a
    u16, so a frame too short for its own VFT header wraps it. Drop such
    a frame, the way the block above it drops a frame with an unknown
    virtual fabric id.
 3  bfa_fcs_lport_scn_process_rscn() is handed that length and ignores it,
    taking the number of RSCN events to walk from the peer's payload
    length field alone. Bound the walk by the received frame length, and
    reject a payload length below the RSCN header it is measured from.

Patch 1 is the source and patches 2 and 3 are two of the sinks; each
stands on its own, and 1 is first because it is the one that makes the
length the others use meaningful.

None of this is tested on hardware; I have no Brocade adapter. All three
were driven through a KUnit harness on a KASAN kernel that injects a frame
completion into uf_recv(), a frame into bfa_fcs_uf_recv(), and frames into
the RSCN and ECHO handlers directly. Without patch 1 a reported length of
2400 reaches bfa_fcs_lport_echo() and its memcpy runs 72 bytes past the
2304-byte request buffer; with it the length is capped at the posted
buffer and a normal frame of FC_MAX_PDUSZ passes through untouched.
Without patch 2 a six-byte VFT-tagged frame hands the FCS a length of
65534. Without patch 3 an RSCN whose payload length exceeds the frame
reads past the frame buffer. With all three, a legitimate RSCN, including
one that fills the frame exactly, parses unchanged.

v4: adds the missing cap on the frame length itself in uf_recv(); v3
    bounded the RSCN walk and the VFT underflow but still trusted a
    firmware-reported length that bfa_fcs_lport_echo() uses to drive an
    out-of-bounds memcpy.
v3: added the VFT-header length underflow guard.
v2: bound the RSCN walk by the received frame length only (dropped a
    buffer-capacity term that did not account for the VFT header offset);
    reject payloads shorter than the RSCN header.

Yehyeong Lee (3):
  scsi: bfa: clamp the received unsolicited frame length to the buffer
  scsi: bfa: drop unsolicited frames shorter than their VFT header
  scsi: bfa: bound the RSCN event list by the received frame length

 drivers/scsi/bfa/bfa_fcs.c       |  5 +++++
 drivers/scsi/bfa/bfa_fcs_lport.c | 19 +++++++++++++++----
 drivers/scsi/bfa/bfa_svc.c       |  2 +-
 3 files changed, 21 insertions(+), 5 deletions(-)


base-commit: 2f2f7eeef8b0a1a9b9ca998231419873ccae8d4e
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-16  8:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16  8:28 [PATCH v4 0/3] scsi: bfa: bound the unsolicited frame receive path Yehyeong Lee
2026-10-16  8:28 ` [PATCH v4 1/3] scsi: bfa: clamp the received unsolicited frame length to the buffer Yehyeong Lee
2026-10-16  8:41   ` sashiko-bot
2026-10-16  8:28 ` [PATCH v4 2/3] scsi: bfa: drop unsolicited frames shorter than their VFT header Yehyeong Lee
2026-10-16  8:44   ` sashiko-bot
2026-10-16  8:28 ` [PATCH v4 3/3] scsi: bfa: bound the RSCN event list by the received frame length Yehyeong Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox