Make the Cramfs code more robust against filesystem corruptions,

plus trivial indentation fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJb2KX1AAoJEH9KYoIL9GO3lfcH/R1eClPzhBbOj/MZWgxoB5VN
 lsOFl2XYc8bhThxOygqKcLpa2De5Q6ebrvLFgQ43erO7MaXzI4mswM5+azIlLXx3
 iVuE1NIYze5g92yvb4mLeDHGVid4EjGoG1tiGRxuU18j02Nze1B7t22tBzcYUCyi
 buJfx0A37aMepd/+cy3Qp4G03hgaNMama1220AR0S0kkORIBZFzKQOAKN6r8DGa/
 05QhmtJJQsLJJxyLDv6lKmy0Ef42COeDICpYUlQ1LvoxJJBAblDBzlkYl7ulORwV
 f147xPV+v/jlE8CktOtN31S8x+XRvbbqm9sKLB0XKnA9vz89WAl1BzoZ/7FZf/Y=
 =aGIT
 -----END PGP SIGNATURE-----

Merge tag 'cramfs_fixes' of git://git.linaro.org/people/nicolas.pitre/linux

Pull cramfs fixes from Nicolas Pitre:
 "Make the Cramfs code more robust against filesystem corruptions, plus
  trivial indentation fixes"

* tag 'cramfs_fixes' of git://git.linaro.org/people/nicolas.pitre/linux:
  Cramfs: trivial whitespace fixes
  Cramfs: fix abad comparison when wrap-arounds occur
This commit is contained in:
Linus Torvalds 2018-10-30 12:46:25 -07:00
commit 9b190ecca1

View File

@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
continue;
blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT;
blk_offset += offset;
if (blk_offset + len > BUFFER_SIZE)
if (blk_offset > BUFFER_SIZE ||
blk_offset + len > BUFFER_SIZE)
continue;
return read_buffers[i] + blk_offset;
}
@ -872,8 +873,8 @@ static int cramfs_readpage(struct file *file, struct page *page)
if (unlikely(block_start & CRAMFS_BLK_FLAG_DIRECT_PTR)) {
/* See comments on earlier code. */
u32 prev_start = block_start;
block_start = prev_start & ~CRAMFS_BLK_FLAGS;
block_start <<= CRAMFS_BLK_DIRECT_PTR_SHIFT;
block_start = prev_start & ~CRAMFS_BLK_FLAGS;
block_start <<= CRAMFS_BLK_DIRECT_PTR_SHIFT;
if (prev_start & CRAMFS_BLK_FLAG_UNCOMPRESSED) {
block_start += PAGE_SIZE;
} else {