[PATCH] fs/buffer.c: grow_buffers: fix the uncorrect check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When pgoff_t index is 32bit, sector_t block is 64bit, need check if block number is too big.
If block is bigger than (4Gb * PAGE_SIZE), index becomes a wrong value.
Commit e5657933863f43cc6bb76a54d659303dafaa9e58 wants to do this. But it gives an uncorrect check.
I think block != index << sizebits is correct. And it can detect such issue above.

Signed-off-by: xinhui.pan <xinhuix.pan@xxxxxxxxx>
---
 fs/buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 9ddb9fc..1a674a6 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1081,7 +1081,7 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
 	 * Check for a block which wants to lie outside our maximum possible
 	 * pagecache index.  (this comparison is done using sector_t types).
 	 */
-	if (unlikely(index != block >> sizebits)) {
+	if (unlikely(block != index << sizebits)) {
 		char b[BDEVNAME_SIZE];
 
 		printk(KERN_ERR "%s: requested out-of-range block %llu for "
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux