Skip to content

Commit

Permalink
Merge tag 'cramfs_fixes' of git://git.linaro.org/people/nicolas.pitre…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
torvalds committed Oct 30, 2018
2 parents 343a9f3 + 56ce68b commit 9b190ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9b190ec

Please sign in to comment.