Skip to contentSkip to conversation

libata: Fix a potential race condition in ata_scsi_park_show()

PATCH Elias Oltmanns 3 participants 6 messages Oct 4, 2008 – Nov 3, 2008 libata

lore
Share & tools
lore
#0 lore raw

Peter Moulder has pointed out that there is a slight chance that a negative value might be passed to jiffies_to_msecs() in ata_scsi_park_show(). This is fixed by saving the value of jiffies in a local variable, thus also reducing code since the volatile variable jiffies is accessed only once.

---
Applies to your upstream branch.

 drivers/ata/libata-scsi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/ata/libata-scsi.c +4 -3
index fccd5e4..e1f916f 100644
@@ -190,7 +190,7 @@ static ssize_t ata_scsi_park_show(struct device *device,
 	struct ata_port *ap;
 	struct ata_link *link;
 	struct ata_device *dev;
-	unsigned long flags;
+	unsigned long flags, now;
 	unsigned int uninitialized_var(msecs);
 	int rc = 0;
 
@@ -208,10 +208,11 @@ static ssize_t ata_scsi_park_show(struct device *device,
 	}
 
 	link = dev->link;
+	now = jiffies;
 	if (ap->pflags & ATA_PFLAG_EH_IN_PROGRESS &&
 	    link->eh_context.unloaded_mask & (1 << dev->devno) &&
-	    time_after(dev->unpark_deadline, jiffies))
-		msecs = jiffies_to_msecs(dev->unpark_deadline - jiffies);
+	    time_after(dev->unpark_deadline, now))
+		msecs = jiffies_to_msecs(dev->unpark_deadline - now);
 	else
 		msecs = 0;
 
#1 lore raw
Quoted 7 lines · Elias Oltmanns

Peter Moulder has pointed out that there is a slight chance that a negative value might be passed to jiffies_to_msecs() in ata_scsi_park_show(). This is fixed by saving the value of jiffies in a local variable, thus also reducing code since the volatile variable jiffies is accessed only once.

added to #tj-upstream. Thanks.

Signature · 1 line
tejun
#2 lore raw
Quoted 11 lines · Tejun Heo
Quoted 8 lines · Elias Oltmanns

Peter Moulder has pointed out that there is a slight chance that a

negative value might be passed to jiffies_to_msecs() in ata_scsi_park_show(). This is fixed by saving the value of jiffies in a local variable, thus also reducing code since the volatile variable jiffies is accessed only once.

added to #tj-upstream. Thanks.

Has this branch been pulled in yet? My patch, for one, is not even in linux-next even though it had been intended for 2.6.28 at the time.

Regards,

Elias

#3 lore raw
Quoted 8 lines · Elias Oltmanns
Quoted 7 lines · Tejun Heo
Quoted 6 lines · Elias Oltmanns

Peter Moulder has pointed out that there is a slight chance that a negative value might be passed to jiffies_to_msecs() in ata_scsi_park_show(). This is fixed by saving the value of jiffies in a local variable, thus also reducing code since the volatile variable jiffies is accessed only once.

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

added to #tj-upstream. Thanks.

Has this branch been pulled in yet? My patch, for one, is not even in linux-next even though it had been intended for 2.6.28 at the time.

Jeff, have you pulled it or taken patches from it?

Thanks.

Signature · 1 line
tejun
#4 lore raw
Quoted 9 lines · Tejun Heo
Quoted 8 lines · Elias Oltmanns
Quoted 7 lines · Tejun Heo
Quoted 6 lines · Elias Oltmanns

Peter Moulder has pointed out that there is a slight chance that a negative value might be passed to jiffies_to_msecs() in ata_scsi_park_show(). This is fixed by saving the value of jiffies in a local variable, thus also reducing code since the volatile variable jiffies is accessed only once.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

added to #tj-upstream. Thanks.

Has this branch been pulled in yet? My patch, for one, is not even in linux-next even though it had been intended for 2.6.28 at the time.

Jeff, have you pulled it or taken patches from it?

Thanks.

I sent an email a couple days ago, asking what was pending (or thought I did...). I haven't pulled from #tj-upstream but I ack'd a big patchset that I assume is included in there.

Jeff

#5 lore raw
Quoted 16 lines · Jeff Garzik
Quoted 15 lines · Tejun Heo
Quoted 13 lines · Elias Oltmanns
Quoted 10 lines · Tejun Heo
Quoted 8 lines · Elias Oltmanns

Peter Moulder has pointed out that there is a slight chance that a negative value might be passed to jiffies_to_msecs() in ata_scsi_park_show(). This is fixed by saving the value of jiffies in a
local variable, thus also reducing code since the volatile variable jiffies is accessed only once.

added to #tj-upstream. Thanks.

Has this branch been pulled in yet? My patch, for one, is not even in linux-next even though it had been intended for 2.6.28 at the time.

Quoted 7 lines
Quoted 3 lines

Jeff, have you pulled it or taken patches from it?

Thanks.

I sent an email a couple days ago, asking what was pending (or thought I did...). I haven't pulled from #tj-upstream but I ack'd a big patchset that I assume is included in there.

Eh... those are different ones. #tj-upstream contained patches scheduled for 2.6.28 (mostly fixes and stuff which were around for quite some time). I'll resend the patchset.

Thanks.

Signature · 1 line
tejun