mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: fcoe: Fix use-after-free after pskb_may_pull() in fcoe_rcv()
@ 2026-11-25 22:19 Elkin Cruz
  2026-11-26  7:23 ` Hannes Reinecke
  0 siblings, 1 reply; 2+ messages in thread
From: Elkin Cruz @ 2026-11-25 22:19 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>
---

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..23d6b9893793 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1365,6 +1365,8 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
 		     !pskb_may_pull(skb, FCOE_HEADER_LEN)))
 		goto err;
 
+	eh = eth_hdr(skb);
+
 	skb_set_transport_header(skb, sizeof(struct fcoe_hdr));
 	fh = (struct fc_frame_header *) skb_transport_header(skb);
 
-- 
2.56.1.839.g22a8290db9-goog


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

* Re: [PATCH] scsi: fcoe: Fix use-after-free after pskb_may_pull() in fcoe_rcv()
  2026-11-25 22:19 [PATCH] scsi: fcoe: Fix use-after-free after pskb_may_pull() in fcoe_rcv() Elkin Cruz
@ 2026-11-26  7:23 ` Hannes Reinecke
  0 siblings, 0 replies; 2+ messages in thread
From: Hannes Reinecke @ 2026-11-26  7:23 UTC (permalink / raw)
  To: Elkin Cruz, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel, llvm, irogers, stable

On 11/25/26 11:19 PM, Elkin Cruz wrote:
> 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>
> ---
> 
> 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..23d6b9893793 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -1365,6 +1365,8 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
>   		     !pskb_may_pull(skb, FCOE_HEADER_LEN)))
>   		goto err;
>   
> +	eh = eth_hdr(skb);
> +
>   	skb_set_transport_header(skb, sizeof(struct fcoe_hdr));
>   	fh = (struct fc_frame_header *) skb_transport_header(skb);
>   

Please move that two lines down, just before
	if (ntoh24(&eh->h_dest[3]) != ntoh24(fh->fh_d_id))

that'll make the patch easier to read. And please add a comment
that the skb->head might have been reallocated.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich

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

end of thread, other threads:[~2026-11-26  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 22:19 [PATCH] scsi: fcoe: Fix use-after-free after pskb_may_pull() in fcoe_rcv() Elkin Cruz
2026-11-26  7:23 ` Hannes Reinecke

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®