Skip to content

Commit

Permalink
libata: Fix accesses at LBA28 boundary (old bug, but nasty) (v2)
Browse files Browse the repository at this point in the history
Most drives from Seagate, Hitachi, and possibly other brands,
do not allow LBA28 access to sector number 0x0fffffff (2^28 - 1).
So instead use LBA48 for such accesses.

This bug could bite a lot of systems, especially when the user has
taken care to align partitions to 4KB boundaries. On misaligned systems,
it is less likely to be encountered, since a 4KB read would end at
0x10000000 rather than at 0x0fffffff.

Signed-off-by: Mark Lord <[email protected]>
Signed-off-by: Jeff Garzik <[email protected]>
  • Loading branch information
Mark Lord authored and Jeff Garzik committed Apr 8, 2010
1 parent cf90bfe commit 45c4d01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/linux/ata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ static inline int ata_ok(u8 status)

static inline int lba_28_ok(u64 block, u32 n_block)
{
/* check the ending block number */
return ((block + n_block) < ((u64)1 << 28)) && (n_block <= 256);
/* check the ending block number: must be LESS THAN 0x0fffffff */
return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
}

static inline int lba_48_ok(u64 block, u32 n_block)
Expand Down

0 comments on commit 45c4d01

Please sign in to comment.