Skip to content

Commit

Permalink
udf: check partition reference in udf_read_inode()
Browse files Browse the repository at this point in the history
We were checking block number without checking partition.
sbi->s_partmaps[iloc->partitionReferenceNum] could lead to
bad memory access. See udf_nfs_get_inode() path for instance.

Signed-off-by: Fabian Frederick <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
Fabian Frederick authored and jankara committed Jan 10, 2017
1 parent 23bcda1 commit 1d82a56
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/udf/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
int ret = -EIO;

reread:
if (iloc->partitionReferenceNum >= sbi->s_partitions) {
udf_debug("partition reference: %d > logical volume partitions: %d\n",
iloc->partitionReferenceNum, sbi->s_partitions);
return -EIO;
}

if (iloc->logicalBlockNum >=
sbi->s_partmaps[iloc->partitionReferenceNum].s_partition_len) {
udf_debug("block=%d, partition=%d out of range\n",
Expand Down

0 comments on commit 1d82a56

Please sign in to comment.