Skip to contentSkip to conversation

scsi: PC partition tables are little endian

PATCH In review Christoph Hellwig 4 participants 4 messages Oct 1, 2014 – Oct 17, 2014 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: PC partition tables are little endian

As sparse correctly pointed out scsi_partsize should use get_unaligned_le32 to read PC partition tables from disk, as they are little endian.

The result of this bug is that we returned incorrect geometries on big endian systems when using the scsicam variant. Which probably doesn't matter as only old x86 systems every cared about the geometry.

---
 drivers/scsi/scsicam.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsicam.c +2 -2
index 92d24d6..910f4a7 100644
@@ -163,8 +163,8 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity,
 		    end_head * end_sector + end_sector;
 
 		/* This is the actual _sector_ number at the end */
-		logical_end = get_unaligned(&largest->start_sect)
-		    + get_unaligned(&largest->nr_sects);
+		logical_end = get_unaligned_le32(&largest->start_sect)
+		    + get_unaligned_le32(&largest->nr_sects);
 
 		/* This is for >1023 cylinders */
 		ext_cyl = (logical_end - (end_head * end_sector + end_sector))
Signature · 1 line
1.9.1
#1 lore raw

ping?

Quoted 34 lines · Christoph Hellwig

As sparse correctly pointed out scsi_partsize should use get_unaligned_le32 to read PC partition tables from disk, as they are little endian.

The result of this bug is that we returned incorrect geometries on big endian systems when using the scsicam variant. Which probably doesn't matter as only old x86 systems every cared about the geometry.

---
 drivers/scsi/scsicam.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsicam.c +2 -2
index 92d24d6..910f4a7 100644
@@ -163,8 +163,8 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity,
 		    end_head * end_sector + end_sector;
 
 		/* This is the actual _sector_ number at the end */
-		logical_end = get_unaligned(&largest->start_sect)
-		    + get_unaligned(&largest->nr_sects);
+		logical_end = get_unaligned_le32(&largest->start_sect)
+		    + get_unaligned_le32(&largest->nr_sects);
 
 		/* This is for >1023 cylinders */
 		ext_cyl = (logical_end - (end_head * end_sector + end_sector))
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

---end quoted text---

Reviewed-by
#2 lore raw
Quoted 11 lines · Christoph Hellwig

ping?

Quoted 8 lines · Christoph Hellwig

As sparse correctly pointed out scsi_partsize should use get_unaligned_le32 to read PC partition tables from disk, as they are little endian.

The result of this bug is that we returned incorrect geometries on big endian systems when using the scsicam variant. Which probably doesn't matter as only old x86 systems every cared about the geometry.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by
#3 lore raw
In reply to Christoph Hellwig
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Christoph" == Christoph Hellwig <[email protected]> writes:

As sparse correctly pointed out scsi_partsize should use get_unaligned_le32 to read PC partition tables from disk, as they are little endian.

The result of this bug is that we returned incorrect geometries on big endian systems when using the scsicam variant. Which probably doesn't matter as only old x86 systems every cared about the geometry.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering