Skip to content

Commit f54e18f

Browse files
committed
isofs: Fix infinite looping over CE entries
Rock Ridge extensions define so called Continuation Entries (CE) which define where is further space with Rock Ridge data. Corrupted isofs image can contain arbitrarily long chain of these, including a one containing loop and thus causing kernel to end in an infinite loop when traversing these entries. Limit the traversal to 32 entries which should be more than enough space to store all the Rock Ridge data. Reported-by: P J P <ppandit@redhat.com> CC: stable@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz>
1 parent fa0c554 commit f54e18f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/isofs/rock.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct rock_state {
3030
int cont_size;
3131
int cont_extent;
3232
int cont_offset;
33+
int cont_loops;
3334
struct inode *inode;
3435
};
3536

@@ -73,6 +74,9 @@ static void init_rock_state(struct rock_state *rs, struct inode *inode)
7374
rs->inode = inode;
7475
}
7576

77+
/* Maximum number of Rock Ridge continuation entries */
78+
#define RR_MAX_CE_ENTRIES 32
79+
7680
/*
7781
* Returns 0 if the caller should continue scanning, 1 if the scan must end
7882
* and -ve on error.
@@ -105,6 +109,8 @@ static int rock_continue(struct rock_state *rs)
105109
goto out;
106110
}
107111
ret = -EIO;
112+
if (++rs->cont_loops >= RR_MAX_CE_ENTRIES)
113+
goto out;
108114
bh = sb_bread(rs->inode->i_sb, rs->cont_extent);
109115
if (bh) {
110116
memcpy(rs->buffer, bh->b_data + rs->cont_offset,

0 commit comments

Comments
 (0)