From a750e58b21c05cffd81f460a72ed4dd6d27ee5ec Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 2 May 2013 01:11:31 +0200 Subject: 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. --- linux/dev/glue/block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux') 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 { -- cgit v1.2.3