mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Chris Leech <christopher.leech@intel.com>,
	Robert Love <robert.w.love@intel.com>,
	James Bottomley <James.Bottomley@suse.de>
Subject: [49/98] [SCSI] libfc: fix memory corruption caused by double frees and bad error handling
Date: Tue, 26 Jan 2010 15:34:15 -0800	[thread overview]
Message-ID: <20100126233927.321178985@mini.kroah.org> (raw)
In-Reply-To: <20100126233950.GA5372@kroah.com>

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Chris Leech <christopher.leech@intel.com>

commit 8f550f937e9fdafa5c37e348e214aecec851ef3f upstream.

I was running into several different panics under stress, which I traced down
to a few different possible slab corruption issues in error handling paths.
I have not yet looked into why these exchange sends fail, but with these
fixes my test system is much more stable under stress than before.

fc_elsct_send() could fail and either leave the passed in frame intact
(failure in fc_ct/els_fill) or the frame could have been freed if the
failure was is fc_exch_seq_send().  The caller had no way of knowing, and
there was a potential double free in the error handling in fc_fcp_rec().

Make fc_elsct_send() always free the frame before returning, and remove the
fc_frame_free() call in fc_fcp_rec().

While fc_exch_seq_send() did always consume the frame, there were double free
bugs in the error handling of fc_fcp_cmd_send() and fc_fcp_srr() as well.

Numerous calls to error handling routines (fc_disc_error(),
fc_lport_error(), fc_rport_error_retry() ) were passing in a frame pointer that
had already been freed in the case of an error.  I have changed the call
sites to pass in a NULL pointer, but there may be more appropriate error
codes to use.

Question:  Why do these error routines take a frame pointer anyway?  I
understand passing in a pointer encoded error to the response handlers, but
the error routines take no action on a valid pointer and should never be
called that way.

Signed-off-by: Chris Leech <christopher.leech@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/scsi/libfc/fc_disc.c  |    2 +-
 drivers/scsi/libfc/fc_elsct.c |    4 +++-
 drivers/scsi/libfc/fc_fcp.c   |    7 ++-----
 drivers/scsi/libfc/fc_lport.c |    8 ++++----
 drivers/scsi/libfc/fc_rport.c |   10 +++++-----
 5 files changed, 15 insertions(+), 16 deletions(-)

--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -371,7 +371,7 @@ static void fc_disc_gpn_ft_req(struct fc
 				 disc, lport->e_d_tov))
 		return;
 err:
-	fc_disc_error(disc, fp);
+	fc_disc_error(disc, NULL);
 }
 
 /**
--- a/drivers/scsi/libfc/fc_elsct.c
+++ b/drivers/scsi/libfc/fc_elsct.c
@@ -53,8 +53,10 @@ static struct fc_seq *fc_elsct_send(stru
 		did = FC_FID_DIR_SERV;
 	}
 
-	if (rc)
+	if (rc) {
+		fc_frame_free(fp);
 		return NULL;
+	}
 
 	fc_fill_fc_hdr(fp, r_ctl, did, fc_host_port_id(lport->host), fh_type,
 		       FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1052,7 +1052,6 @@ static int fc_fcp_cmd_send(struct fc_lpo
 
 	seq = lp->tt.exch_seq_send(lp, fp, resp, fc_fcp_pkt_destroy, fsp, 0);
 	if (!seq) {
-		fc_frame_free(fp);
 		rc = -1;
 		goto unlock;
 	}
@@ -1317,7 +1316,6 @@ static void fc_fcp_rec(struct fc_fcp_pkt
 		fc_fcp_pkt_hold(fsp);		/* hold while REC outstanding */
 		return;
 	}
-	fc_frame_free(fp);
 retry:
 	if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY)
 		fc_fcp_timer_set(fsp, FC_SCSI_REC_TOV);
@@ -1565,10 +1563,9 @@ static void fc_fcp_srr(struct fc_fcp_pkt
 
 	seq = lp->tt.exch_seq_send(lp, fp, fc_fcp_srr_resp, NULL,
 				   fsp, jiffies_to_msecs(FC_SCSI_REC_TOV));
-	if (!seq) {
-		fc_frame_free(fp);
+	if (!seq)
 		goto retry;
-	}
+
 	fsp->recov_seq = seq;
 	fsp->xfer_len = offset;
 	fsp->xfer_contig_end = offset;
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -1115,7 +1115,7 @@ static void fc_lport_enter_scr(struct fc
 
 	if (!lport->tt.elsct_send(lport, FC_FID_FCTRL, fp, ELS_SCR,
 				  fc_lport_scr_resp, lport, lport->e_d_tov))
-		fc_lport_error(lport, fp);
+		fc_lport_error(lport, NULL);
 }
 
 /**
@@ -1186,7 +1186,7 @@ static void fc_lport_enter_rpn_id(struct
 	if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RPN_ID,
 				  fc_lport_rpn_id_resp,
 				  lport, lport->e_d_tov))
-		fc_lport_error(lport, fp);
+		fc_lport_error(lport, NULL);
 }
 
 static struct fc_rport_operations fc_lport_rport_ops = {
@@ -1340,7 +1340,7 @@ static void fc_lport_enter_logo(struct f
 
 	if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, ELS_LOGO,
 				  fc_lport_logo_resp, lport, lport->e_d_tov))
-		fc_lport_error(lport, fp);
+		fc_lport_error(lport, NULL);
 }
 
 /**
@@ -1456,7 +1456,7 @@ void fc_lport_enter_flogi(struct fc_lpor
 
 	if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, ELS_FLOGI,
 				  fc_lport_flogi_resp, lport, lport->e_d_tov))
-		fc_lport_error(lport, fp);
+		fc_lport_error(lport, NULL);
 }
 
 /* Configure a fc_lport */
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -632,7 +632,7 @@ static void fc_rport_enter_plogi(struct 
 
 	if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PLOGI,
 				  fc_rport_plogi_resp, rdata, lport->e_d_tov))
-		fc_rport_error_retry(rdata, fp);
+		fc_rport_error_retry(rdata, NULL);
 	else
 		kref_get(&rdata->kref);
 }
@@ -793,7 +793,7 @@ static void fc_rport_enter_prli(struct f
 
 	if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PRLI,
 				  fc_rport_prli_resp, rdata, lport->e_d_tov))
-		fc_rport_error_retry(rdata, fp);
+		fc_rport_error_retry(rdata, NULL);
 	else
 		kref_get(&rdata->kref);
 }
@@ -889,7 +889,7 @@ static void fc_rport_enter_rtv(struct fc
 
 	if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV,
 				     fc_rport_rtv_resp, rdata, lport->e_d_tov))
-		fc_rport_error_retry(rdata, fp);
+		fc_rport_error_retry(rdata, NULL);
 	else
 		kref_get(&rdata->kref);
 }
@@ -919,7 +919,7 @@ static void fc_rport_enter_logo(struct f
 
 	if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_LOGO,
 				  fc_rport_logo_resp, rdata, lport->e_d_tov))
-		fc_rport_error_retry(rdata, fp);
+		fc_rport_error_retry(rdata, NULL);
 	else
 		kref_get(&rdata->kref);
 }
@@ -1006,7 +1006,7 @@ static void fc_rport_enter_adisc(struct 
 	}
 	if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_ADISC,
 				  fc_rport_adisc_resp, rdata, lport->e_d_tov))
-		fc_rport_error_retry(rdata, fp);
+		fc_rport_error_retry(rdata, NULL);
 	else
 		kref_get(&rdata->kref);
 }



  parent reply	other threads:[~2010-01-26 23:53 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-26 23:39 [00/98] 2.6.32.7-stable review Greg KH
2010-01-26 23:33 ` [01/98] clockevent: Dont remove broadcast device when cpu is dead Greg KH
2010-01-26 23:33 ` [02/98] clockevents: Add missing include to pacify sparse Greg KH
2010-01-26 23:33 ` [03/98] ACPI: dont cond_resched if irq is disabled Greg KH
2010-01-26 23:33 ` [04/98] sfc: Fix DMA mapping cleanup in case of an error in TSO Greg KH
2010-01-26 23:33 ` [05/98] be2net: Add support for next generation of BladeEngine device Greg KH
2010-01-26 23:33 ` [06/98] be2net: Add the new PCI IDs to PCI_DEVICE_TABLE Greg KH
2010-01-26 23:33 ` [07/98] [SCSI] mpt2sas: New device SAS2208 support is added Greg KH
2010-01-26 23:33 ` [08/98] ar9170: Add support for D-Link DWA 160 A2 Greg KH
2010-01-26 23:33 ` [09/98] [stable] [PATCH] powerpc/fsl: Add PCI device ids for new QoirQ chips Greg KH
2010-01-26 23:33 ` [10/98] davinci: dm646x: Add support for 3.x silicon revision Greg KH
2010-01-26 23:33 ` [11/98] Input: ALPS - add interleaved protocol support (Dell E6x00 series) Greg KH
2010-01-26 23:33 ` [12/98] Driver-Core: devtmpfs - set root directory mode to 0755 Greg KH
2010-01-27  4:09   ` Kay Sievers
2010-01-27 16:35     ` Greg KH
2010-01-26 23:33 ` [13/98] driver-core: fix devtmpfs crash on s390 Greg KH
2010-01-26 23:33 ` [14/98] ALSA: hda - Add PCI IDs for Nvidia G2xx-series Greg KH
2010-01-26 23:33 ` [15/98] V4L/DVB (13569): smsusb: add autodetection support for five additional Hauppauge USB IDs Greg KH
2010-01-26 23:33 ` [16/98] USB: mos7840: add device IDs for B&B electronics devices Greg KH
2010-01-26 23:33 ` [17/98] USB: ftdi_sio: add USB device IDs for B&B Electronics line Greg KH
2010-01-26 23:33 ` [18/98] V4L/DVB (13168): Add support for Asus Europa Hybrid DVB-T card (SAA7134 SubVendor ID: 0x1043 Device ID: 0x4847) Greg KH
2010-01-26 23:33 ` [19/98] [WATCHDOG] iTCO_wdt: Add support for Intel Ibex Peak Greg KH
2010-01-26 23:33 ` [20/98] atl1c:use common_task instead of reset_task and link_chg_task Greg KH
2010-01-27  5:25   ` [Stable-review] " Willy Tarreau
2010-01-27 14:45     ` Stefan Bader
2010-01-30 18:09     ` Willy Tarreau
2010-01-26 23:33 ` [21/98] atl1e:disable NETIF_F_TSO6 for hardware limit Greg KH
2010-01-26 23:33 ` [22/98] V4L/DVB (13680a): DocBook/media: copy images after building HTML Greg KH
2010-01-26 23:33 ` [23/98] V4L/DVB (13680b): DocBook/media: create links for included sources Greg KH
2010-01-26 23:33 ` [24/98] netfilter: xtables: fix conntrack match v1 ipt-save output Greg KH
2010-01-26 23:33 ` [25/98] partitions: read whole sector with EFI GPT header Greg KH
2010-01-26 23:33 ` [26/98] partitions: use sector size for EFI GPT Greg KH
2010-01-26 23:33 ` [27/98] ALSA: ice1724 - Patch for suspend/resume for ESI Juli@ Greg KH
2010-01-26 23:33 ` [28/98] sched: Fix isolcpus boot option Greg KH
2010-01-26 23:33 ` [29/98] sched: Fix missing sched tunable recalculation on cpu add/remove Greg KH
2010-01-26 23:33 ` [30/98] nohz: Prevent clocksource wrapping during idle Greg KH
2010-01-26 23:33 ` [31/98] nfsd: Fix sort_pacl in fs/nfsd/nf4acl.c to actually sort groups Greg KH
2010-01-26 23:33 ` [32/98] timers, init: Limit the number of per cpu calibration bootup messages Greg KH
2010-01-26 23:33 ` [33/98] PCI: Always set prefetchable base/limit upper32 registers Greg KH
2010-01-26 23:34 ` [34/98] [SCSI] iscsi class: modify handling of replacement timeout Greg KH
2010-01-26 23:34 ` [35/98] NFS: Revert default r/wsize behavior Greg KH
2010-01-26 23:34 ` [36/98] HID: fixup quirk for NCR devices Greg KH
2010-01-26 23:34 ` [37/98] [SCSI] scsi_devinfo: update Hitachi entries (v2) Greg KH
2010-01-26 23:34 ` [38/98] [SCSI] scsi_dh: create sysfs file, dh_state for all SCSI disk devices Greg KH
2010-01-26 23:34 ` [39/98] [SCSI] scsi_transport_fc: remove invalid BUG_ON Greg KH
2010-01-26 23:34 ` [40/98] [SCSI] lpfc: fix hang on SGI ia64 platform Greg KH
2010-01-26 23:34 ` [41/98] [SCSI] libfc: fix typo in retry check on received PRLI Greg KH
2010-01-26 23:34 ` [42/98] [SCSI] libfc: fix ddp in fc_fcp for 0 xid Greg KH
2010-01-26 23:34 ` [43/98] [SCSI] fcoe: remove redundant checking of netdev->netdev_ops Greg KH
2010-01-26 23:34 ` [44/98] [SCSI] libfc: Fix wrong scsi return status under FC_DATA_UNDRUN Greg KH
2010-01-26 23:34 ` [45/98] [SCSI] libfc: lport: fix minor documentation errors Greg KH
2010-01-26 23:34 ` [46/98] [SCSI] libfc: dont WARN_ON in lport_timeout for RESET state Greg KH
2010-01-26 23:34 ` [47/98] [SCSI] fcoe: initialize return value in fcoe_destroy Greg KH
2010-01-26 23:34 ` [48/98] [SCSI] libfc: Fix frags in frame exceeding SKB_MAX_FRAGS in fc_fcp_send_data Greg KH
2010-01-26 23:34 ` Greg KH [this message]
2010-01-26 23:34 ` [50/98] [SCSI] libfc: fix free of fc_rport_priv with timer pending Greg KH
2010-01-27  0:03   ` Joe Eykholt
2010-01-27  2:03     ` Greg KH
2010-01-26 23:34 ` [51/98] [SCSI] fcoe, libfc: fix an libfc issue with queue ramp down in libfc Greg KH
2010-01-26 23:34 ` [52/98] [SCSI] fcoe: Fix checking san mac address Greg KH
2010-01-26 23:34 ` [53/98] [SCSI] fcoe: Fix getting san mac for VLAN interface Greg KH
2010-01-26 23:34 ` [54/98] qlge: Remove explicit setting of PCI Dev CTL reg Greg KH
2010-01-26 23:34 ` [55/98] qlge: Set PCIE max read request size Greg KH
2010-01-26 23:34 ` [56/98] qlge: Dont fail open when port is not initialized Greg KH
2010-01-26 23:34 ` [57/98] qlge: Add handler for DCBX firmware event Greg KH
2010-01-26 23:34 ` [58/98] qlge: Bonding fix for mode 6 Greg KH
2010-01-26 23:34 ` [59/98] PCI: AER: fix aer inject result in kernel oops Greg KH
2010-01-26 23:34 ` [60/98] DMI: allow omitting ident strings in DMI tables Greg KH
2010-01-26 23:34 ` [61/98] Input: i8042 - remove identification strings from " Greg KH
2010-01-27  0:00   ` Linus Torvalds
2010-01-27  0:11     ` Greg KH
2010-01-26 23:34 ` [62/98] Input: i8042 - add Gigabyte M1022M to the noloop list Greg KH
2010-01-26 23:34 ` [63/98] Input: i8042 - add Dritek quirk for Acer Aspire 5610 Greg KH
2010-01-26 23:34 ` [64/98] ALSA: hda - select IbexPeak handler for Calpella Greg KH
2010-01-26 23:34 ` [65/98] ALSA: hda - Fix quirk for Maxdata obook4-1 Greg KH
2010-01-26 23:34 ` [66/98] ALSA: hda - Add missing Line-Out and PCM switches as slave Greg KH
2010-01-26 23:34 ` [67/98] [WATCHDOG] iTCO_wdt.c - cleanup chipset documentation Greg KH
2010-01-26 23:34 ` [68/98] [WATCHDOG] iTCO_wdt: add PCI ID for the Intel EP80579 (Tolapai) SoC Greg KH
2010-01-26 23:34 ` [69/98] [WATCHDOG] iTCO_wdt: Add Intel Cougar Point and PCH DeviceIDs Greg KH
2010-01-26 23:34 ` [70/98] ahci: disable SNotification capability for ich8 Greg KH
2010-01-26 23:34 ` [71/98] ata_piix: fix MWDMA handling on PIIX3 Greg KH
2010-01-26 23:34 ` [72/98] ata_piix: enable 32bit PIO on SATA piix Greg KH
2010-01-26 23:56   ` Tejun Heo
2010-01-27  0:03     ` Greg KH
2010-01-26 23:34 ` [73/98] md: fix small irregularity with start_ro module parameter Greg KH
2010-01-26 23:34 ` [74/98] V4L/DVB (13826): uvcvideo: Fix controls blacklisting Greg KH
2010-01-26 23:34 ` [75/98] [S390] cio: fix double free in case of probe failure Greg KH
2010-01-26 23:34 ` [76/98] [S390] cio: dont panic in non-fatal conditions Greg KH
2010-01-26 23:34 ` [77/98] netiucv: displayed TX bytes value much too high Greg KH
2010-01-26 23:34 ` [78/98] ipc ns: fix memory leak (idr) Greg KH
2010-01-26 23:34 ` [79/98] ALSA: hda - Fix HP T5735 automute Greg KH
2010-01-26 23:34 ` [80/98] hwmon: (fschmd) Fix a memleak on multiple opens of /dev/watchdog Greg KH
2010-01-26 23:34 ` [81/98] UBI: fix memory leak in update path Greg KH
2010-01-26 23:34 ` [82/98] UBI: initialise update marker Greg KH
2010-01-26 23:34 ` [83/98] ASoC: fix a memory-leak in wm8903 Greg KH
2010-01-26 23:34 ` [84/98] mac80211: check that ieee80211_set_power_mgmt only handles STA interfaces Greg KH
2010-01-26 23:34 ` [85/98] cfg80211: fix channel setting for wext Greg KH
2010-01-26 23:34 ` [86/98] KVM: S390: fix potential array overrun in intercept handling Greg KH
2010-01-26 23:34 ` [87/98] KVM: only allow one gsi per fd Greg KH
2010-01-26 23:34 ` [88/98] KVM: Fix race between APIC TMR and IRR Greg KH
2010-01-26 23:34 ` [89/98] KVM: MMU: bail out pagewalk on kvm_read_guest error Greg KH
2010-01-26 23:34 ` [90/98] KVM: x86: Fix host_mapping_level() Greg KH
2010-01-26 23:34 ` [91/98] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Greg KH
2010-01-26 23:34 ` [92/98] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init() Greg KH
2010-01-26 23:34 ` [93/98] KVM: fix lock imbalance in kvm_*_irq_source_id() Greg KH
2010-01-26 23:35 ` [94/98] KVM: only clear irq_source_id if irqchip is present Greg KH
2010-01-26 23:35 ` [95/98] IPoIB: Clear ipoib_neigh.dgid in ipoib_neigh_alloc() Greg KH
2010-01-26 23:35 ` [96/98] x86: Reenable TSC sync check at boot, even with NONSTOP_TSC Greg KH
2010-01-26 23:35 ` [97/98] ACPI: enable C2 and Turbo-mode on Nehalem notebooks on A/C Greg KH
2010-01-26 23:35 ` [98/98] iwlwifi: Fix throughput stall issue in HT mode for 5000 Greg KH

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=20100126233927.321178985@mini.kroah.org \
    --to=gregkh@suse.de \
    --cc=James.Bottomley@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=christopher.leech@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robert.w.love@intel.com \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

Powered by JetHome