From: Greg Kroah-Hartman Date: Tue, 11 Feb 2014 00:14:35 +0000 (-0800) Subject: 3.13-stable patches X-Git-Tag: v3.4.80~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=677f491b96d86777371b8c6026941ffc4092f911;p=thirdparty%2Fkernel%2Fstable-queue.git 3.13-stable patches added patches: target-fix-percpu_ref_put-race-in-transport_lun_remove_cmd.patch --- diff --git a/queue-3.13/series b/queue-3.13/series index abd4cfc52c8..0546111512a 100644 --- a/queue-3.13/series +++ b/queue-3.13/series @@ -86,3 +86,4 @@ drm-radeon-set-si_notify_smc_display_change-properly.patch drm-radeon-dce4-clear-bios-scratch-dpms-bit-v2.patch drm-radeon-dce8-workaround-for-atom-blankcrtc-table.patch dm-sysfs-fix-a-module-unload-race.patch +target-fix-percpu_ref_put-race-in-transport_lun_remove_cmd.patch diff --git a/queue-3.13/target-fix-percpu_ref_put-race-in-transport_lun_remove_cmd.patch b/queue-3.13/target-fix-percpu_ref_put-race-in-transport_lun_remove_cmd.patch new file mode 100644 index 00000000000..159100a1999 --- /dev/null +++ b/queue-3.13/target-fix-percpu_ref_put-race-in-transport_lun_remove_cmd.patch @@ -0,0 +1,61 @@ +From 5259a06ef97068b710f45d092a587e8d740f750f Mon Sep 17 00:00:00 2001 +From: Nicholas Bellinger +Date: Tue, 28 Jan 2014 17:56:30 -0800 +Subject: target: Fix percpu_ref_put race in transport_lun_remove_cmd + +From: Nicholas Bellinger + +commit 5259a06ef97068b710f45d092a587e8d740f750f upstream. + +This patch fixes a percpu_ref_put race for se_lun->lun_ref in +transport_lun_remove_cmd() where ->lun_ref could end up being +put more than once per command via different target completion +and fabric release contexts. + +It adds a cmpxchg() for se_cmd->lun_ref_active to ensure that +percpu_ref_put() is only ever called once per se_cmd. + +This bug was manifesting itself as a LUN shutdown regression +bug in >= v3.13 code, where percpu_ref_kill() would end up +hanging indefinately due to the incorrect percpu_ref count. + +(Change se_cmd->lun_ref_active from bool -> int to force at + least a 4-byte cmpxchg with MIPS ll/sc ins. - Fengguang) + +Reported-by: Tommy Apel +Cc: Tommy Apel +Signed-off-by: Nicholas Bellinger +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/target/target_core_transport.c | 5 +++-- + include/target/target_core_base.h | 2 +- + 2 files changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/target/target_core_transport.c ++++ b/drivers/target/target_core_transport.c +@@ -568,10 +568,11 @@ static void transport_lun_remove_cmd(str + { + struct se_lun *lun = cmd->se_lun; + +- if (!lun || !cmd->lun_ref_active) ++ if (!lun) + return; + +- percpu_ref_put(&lun->lun_ref); ++ if (cmpxchg(&cmd->lun_ref_active, true, false)) ++ percpu_ref_put(&lun->lun_ref); + } + + void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) +--- a/include/target/target_core_base.h ++++ b/include/target/target_core_base.h +@@ -497,7 +497,7 @@ struct se_cmd { + void *priv; + + /* Used for lun->lun_ref counting */ +- bool lun_ref_active; ++ int lun_ref_active; + }; + + struct se_ua {