Skip to content

Commit

Permalink
isofs: fix minor filesystem corruption
Browse files Browse the repository at this point in the history
Some iso9660 images contain files with rockridge data that is either
incorrect or incompletely parsed.  Prior to commit
f296663 ("[PATCH] rock: handle directory
overflows") (included with kernel 2.6.13) the kernel ignored the rockridge
data for these files, while still allowing the files to be accessed under
their non-rockridge names.  That commit inadvertently changed things so
that files with invalid rockridge data could not be accessed at all.  (I
ran across the problem when comparing some old CDs with hard disk copies I
had made long ago under kernel 2.4: a few of the files on the hard disk
copies were no longer visible on the CDs.)

This change reverts to the pre-2.6.13 behavior.

Signed-off-by: Adam Greenblatt <adam.greenblatt@gmail.com>
Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: <stable@kernel.org>		[2.6.25.x, 2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Adam Greenblatt authored and Linus Torvalds committed Jul 25, 2008
1 parent 275c0a8 commit c0a1633
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions fs/isofs/rock.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,24 @@ int get_rock_ridge_filename(struct iso_directory_record *de,

while (rs.len > 2) { /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *)rs.chr;
/*
* Ignore rock ridge info if rr->len is out of range, but
* don't return -EIO because that would make the file
* invisible.
*/
if (rr->len < 3)
goto out; /* Something got screwed up here */
sig = isonum_721(rs.chr);
if (rock_check_overflow(&rs, sig))
goto eio;
rs.chr += rr->len;
rs.len -= rr->len;
/*
* As above, just ignore the rock ridge info if rr->len
* is bogus.
*/
if (rs.len < 0)
goto eio; /* corrupted isofs */
goto out; /* Something got screwed up here */

switch (sig) {
case SIG('R', 'R'):
Expand Down Expand Up @@ -307,15 +316,24 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
repeat:
while (rs.len > 2) { /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *)rs.chr;
/*
* Ignore rock ridge info if rr->len is out of range, but
* don't return -EIO because that would make the file
* invisible.
*/
if (rr->len < 3)
goto out; /* Something got screwed up here */
sig = isonum_721(rs.chr);
if (rock_check_overflow(&rs, sig))
goto eio;
rs.chr += rr->len;
rs.len -= rr->len;
/*
* As above, just ignore the rock ridge info if rr->len
* is bogus.
*/
if (rs.len < 0)
goto eio; /* corrupted isofs */
goto out; /* Something got screwed up here */

switch (sig) {
#ifndef CONFIG_ZISOFS /* No flag for SF or ZF */
Expand Down

0 comments on commit c0a1633

Please sign in to comment.