* [PATCH v2] scsi: fcoe: Fix use-after-free after pskb_may_pull() in fcoe_rcv()
@ 2026-12-02 0:38 Elkin Cruz
0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-12-02 0:38 UTC (permalink / raw)
To: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen
Cc: linux-scsi, linux-kernel, llvm, irogers, Elkin Cruz, stable
In fcoe_rcv(), eh = eth_hdr(skb) is cached before pskb_may_pull(). If
pskb_may_pull() reallocates skb->head, eh is left pointing to freed
memory when validating eh->h_dest against the FC frame header.
Re-evaluate eh = eth_hdr(skb) after pskb_may_pull() succeeds.
Fixes: 0ee31cb5df4b ("[SCSI] fcoe: Fix broken NPIV with correction to MAC validation")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
Changes in v2:
- Move eh = eth_hdr(skb) right before the h_dest check and add a comment
that skb->head may have been reallocated (thanks Hannes for the review).
v1: https://lore.kernel.org/r/20261125221921.1425747-1-elkin@google.com
I am trying out new Clang static analysis checks for kernel bug
classes, and they flagged this code as possibly buggy. The findings
were triaged/fixed and commit descriptions were drafted with help of AI,
then checked against linux-next (not runtime-tested on hardware).
Thanks,
Elkin
drivers/scsi/fcoe/fcoe.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index a2cf65fac297..2ad52241f103 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1368,6 +1368,8 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
skb_set_transport_header(skb, sizeof(struct fcoe_hdr));
fh = (struct fc_frame_header *) skb_transport_header(skb);
+ /* Re-fetch eh as pskb_may_pull() may have reallocated skb->head. */
+ eh = eth_hdr(skb);
if (ntoh24(&eh->h_dest[3]) != ntoh24(fh->fh_d_id)) {
FCOE_NETDEV_DBG(netdev, "FC frame d_id mismatch with MAC:%pM\n",
eh->h_dest);
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 0:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 0:38 [PATCH v2] scsi: fcoe: Fix use-after-free after pskb_may_pull() in fcoe_rcv() Elkin Cruz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®