Patchwork [Open-FCoE,RHEL7,2/3] fcoe: make sure fcoe frames are unshared prior to manipulating them

login
register
mail settings
Submitter Neil Horman
Date Aug. 3, 2013, 2:45 a.m.
Message ID <1375497955-32659-3-git-send-email-nhorman@redhat.com>
Download mbox | patch
Permalink /patch/79/
State Accepted
Headers show

Comments

Neil Horman - Aug. 3, 2013, 2:45 a.m.
From: Neil Horman <nhorman@tuxdriver.com>

Based on my last patch I noticed that fcoe_rcv has a simmilar problem, in that
it manipulates the passed in skb without checking to see if it has other users.
Making manipulations to a shared skb can result in various corruptions.

Easy fix, just make sure the skb is unshared prior to doing anything with it.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Robert Love <robert.w.love@intel.com>
---
 drivers/scsi/fcoe/fcoe.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 3336e57..5cb2e02 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1452,6 +1452,12 @@  static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
 			skb_tail_pointer(skb), skb_end_pointer(skb),
 			skb->csum, skb->dev ? skb->dev->name : "<NULL>");
 
+
+	skb = skb_share_check(skb, GFP_ATOMIC);
+
+	if (skb == NULL)
+		return NET_RX_DROP;
+
 	eh = eth_hdr(skb);
 
 	if (is_fip_mode(ctlr) &&