summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-05-02 01:11:31 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-05-02 01:11:31 +0200
commita750e58b21c05cffd81f460a72ed4dd6d27ee5ec (patch)
tree170d370c707f98dcbe90b1b9f92ff58b8b19520f
parent0e40fde7b8b9ff050b41ca62e86a91dec726972e (diff)
Fix non-block-aligned-offset reads
This fixes grave issues when device_read is called with non-block-aligned offset, e.g. when using grub-probe with a non-block-aligned partition table. * linux/dev/glue/block.c (rdwr_full): Use current position instead of base buffer position to check for alignment.
-rw-r--r--linux/dev/glue/block.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c
index 745e93a..011b6f5 100644
--- a/linux/dev/glue/block.c
+++ b/linux/dev/glue/block.c
@@ -589,8 +589,8 @@ rdwr_full (int rw, kdev_t dev, loff_t *off, char **buf, int *resid, int bshift)
set_bit (BH_Lock, &bh->b_state);
if (rw == WRITE)
set_bit (BH_Dirty, &bh->b_state);
- cc = PAGE_SIZE - (((int) *buf) & PAGE_MASK);
- if (cc >= BSIZE && ((int) *buf & 511) == 0)
+ cc = PAGE_SIZE - (((int) *buf + (nb << bshift)) & PAGE_MASK);
+ if (cc >= BSIZE && (((int) *buf + (nb << bshift)) & 511) == 0)
cc &= ~BMASK;
else
{