Skip to content

Commit

Permalink
fs/hfs/extent.c: fix array out of bounds read of array extent
Browse files Browse the repository at this point in the history
Currently extent and index i are both being incremented causing an array
out of bounds read on extent[i].  Fix this by removing the extraneous
increment of extent.

Ernesto said:

: This is only triggered when deleting a file with a resource fork.  I
: may be wrong because the documentation isn't clear, but I don't think
: you can create those under linux.  So I guess nobody was testing them.
:
: > A disk space leak, perhaps?
:
: That's what it looks like in general.  hfs_free_extents() won't do
: anything if the block count doesn't add up, and the error will be
: ignored.  Now, if the block count randomly does add up, we could see
: some corruption.

Detected by CoverityScan, CID#711541 ("Out of bounds read")

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Colin Ian King <[email protected]>
Reviewed-by: Ernesto A. Fernndez <[email protected]>
Cc: David Howells <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Hin-Tak Leung <[email protected]>
Cc: Vyacheslav Dubeyko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Colin Ian King authored and torvalds committed Oct 31, 2018
1 parent 8cd3cb5 commit 6c9a3f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/hfs/extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
return 0;

blocks = 0;
for (i = 0; i < 3; extent++, i++)
for (i = 0; i < 3; i++)
blocks += be16_to_cpu(extent[i].count);

res = hfs_free_extents(sb, extent, blocks, blocks);
Expand Down

0 comments on commit 6c9a3f8

Please sign in to comment.