diff options
author | Chris Leech <christopher.leech@intel.com> | 2009-10-21 19:28:09 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:00:34 -0500 |
commit | 8f550f937e9fdafa5c37e348e214aecec851ef3f (patch) | |
tree | 589cc0df120e995aaefb26ea0e353c4ecc789bc4 /drivers/scsi/libfc/fc_rport.c | |
parent | b7a727f1af953b00352d3a4b6c458c6e2872f94b (diff) |
[SCSI] libfc: fix memory corruption caused by double frees and bad error handling
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>
Diffstat (limited to 'drivers/scsi/libfc/fc_rport.c')
-rw-r--r-- | drivers/scsi/libfc/fc_rport.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 1f795e4e4742..49abb839a223 100644 --- 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 fc_rport_priv *rdata) | |||
632 | 632 | ||
633 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PLOGI, | 633 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PLOGI, |
634 | fc_rport_plogi_resp, rdata, lport->e_d_tov)) | 634 | fc_rport_plogi_resp, rdata, lport->e_d_tov)) |
635 | fc_rport_error_retry(rdata, fp); | 635 | fc_rport_error_retry(rdata, NULL); |
636 | else | 636 | else |
637 | kref_get(&rdata->kref); | 637 | kref_get(&rdata->kref); |
638 | } | 638 | } |
@@ -793,7 +793,7 @@ static void fc_rport_enter_prli(struct fc_rport_priv *rdata) | |||
793 | 793 | ||
794 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PRLI, | 794 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PRLI, |
795 | fc_rport_prli_resp, rdata, lport->e_d_tov)) | 795 | fc_rport_prli_resp, rdata, lport->e_d_tov)) |
796 | fc_rport_error_retry(rdata, fp); | 796 | fc_rport_error_retry(rdata, NULL); |
797 | else | 797 | else |
798 | kref_get(&rdata->kref); | 798 | kref_get(&rdata->kref); |
799 | } | 799 | } |
@@ -889,7 +889,7 @@ static void fc_rport_enter_rtv(struct fc_rport_priv *rdata) | |||
889 | 889 | ||
890 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV, | 890 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV, |
891 | fc_rport_rtv_resp, rdata, lport->e_d_tov)) | 891 | fc_rport_rtv_resp, rdata, lport->e_d_tov)) |
892 | fc_rport_error_retry(rdata, fp); | 892 | fc_rport_error_retry(rdata, NULL); |
893 | else | 893 | else |
894 | kref_get(&rdata->kref); | 894 | kref_get(&rdata->kref); |
895 | } | 895 | } |
@@ -919,7 +919,7 @@ static void fc_rport_enter_logo(struct fc_rport_priv *rdata) | |||
919 | 919 | ||
920 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_LOGO, | 920 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_LOGO, |
921 | fc_rport_logo_resp, rdata, lport->e_d_tov)) | 921 | fc_rport_logo_resp, rdata, lport->e_d_tov)) |
922 | fc_rport_error_retry(rdata, fp); | 922 | fc_rport_error_retry(rdata, NULL); |
923 | else | 923 | else |
924 | kref_get(&rdata->kref); | 924 | kref_get(&rdata->kref); |
925 | } | 925 | } |
@@ -1006,7 +1006,7 @@ static void fc_rport_enter_adisc(struct fc_rport_priv *rdata) | |||
1006 | } | 1006 | } |
1007 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_ADISC, | 1007 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_ADISC, |
1008 | fc_rport_adisc_resp, rdata, lport->e_d_tov)) | 1008 | fc_rport_adisc_resp, rdata, lport->e_d_tov)) |
1009 | fc_rport_error_retry(rdata, fp); | 1009 | fc_rport_error_retry(rdata, NULL); |
1010 | else | 1010 | else |
1011 | kref_get(&rdata->kref); | 1011 | kref_get(&rdata->kref); |
1012 | } | 1012 | } |