This is a note to let you know that I've just added the patch titled
libata: fix NULL sdev dereference race in atapi_qc_complete()
to the 2.6.32-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
libata-fix-null-sdev-dereference-race-in-atapi_qc_complete.patch
and it can be found in the queue-2.6.32 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From 2a5f07b5ec098edc69e05fdd2f35d3fbb1235723 Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Mon, 1 Nov 2010 11:39:19 +0100
Subject: libata: fix NULL sdev dereference race in atapi_qc_complete()
From: Tejun Heo <[email protected]>
commit 2a5f07b5ec098edc69e05fdd2f35d3fbb1235723 upstream.
SCSI commands may be issued between __scsi_add_device() and dev->sdev
assignment, so it's unsafe for ata_qc_complete() to dereference
dev->sdev->locked without checking whether it's NULL or not. Fix it.
Signed-off-by: Tejun Heo <[email protected]>
Signed-off-by: Jeff Garzik <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/ata/libata-scsi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2497,8 +2497,11 @@ static void atapi_qc_complete(struct ata
*
* If door lock fails, always clear sdev->locked to
* avoid this infinite loop.
+ *
+ * This may happen before SCSI scan is complete. Make
+ * sure qc->dev->sdev isn't NULL before dereferencing.
*/
- if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL)
+ if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
qc->dev->sdev->locked = 0;
qc->scsicmd->result = SAM_STAT_CHECK_CONDITION;
Patches currently in stable-queue which might be from [email protected] are
queue-2.6.32/libata-fix-null-sdev-dereference-race-in-atapi_qc_complete.patch
queue-2.6.32/ata_generic-implement-ata_gen_-flags-and-force-enable-dma-on-mbp-7-1.patch
queue-2.6.32/percpu-fix-list_head-init-bug-in-__percpu_counter_init.patch
queue-2.6.32/ahci-ata_generic-let-ata_generic-handle-new-mbp-w-mcp89.patch
_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable