isofs: Fix unbounded recursion when processing relocated directories
We did not check relocated directory in any way when processing Rock Ridge 'CL' tag. Thus a corrupted isofs image can possibly have a CL entry pointing to another CL entry leading to possibly unbounded recursion in kernel code and thus stack overflow or deadlocks (if there is a loop created from CL entries). Fix the problem by not allowing CL entry to point to a directory entry with CL entry (such use makes no good sense anyway) and by checking whether CL entry doesn't point to itself. CC: stable@vger.kernel.org Reported-by: Chris Evans <cevans@google.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
@@ -61,7 +61,7 @@ static void isofs_put_super(struct super_block *sb)
|
||||
return;
|
||||
}
|
||||
|
||||
static int isofs_read_inode(struct inode *);
|
||||
static int isofs_read_inode(struct inode *, int relocated);
|
||||
static int isofs_statfs (struct dentry *, struct kstatfs *);
|
||||
|
||||
static struct kmem_cache *isofs_inode_cachep;
|
||||
@@ -1259,7 +1259,7 @@ out_toomany:
|
||||
goto out;
|
||||
}
|
||||
|
||||
static int isofs_read_inode(struct inode *inode)
|
||||
static int isofs_read_inode(struct inode *inode, int relocated)
|
||||
{
|
||||
struct super_block *sb = inode->i_sb;
|
||||
struct isofs_sb_info *sbi = ISOFS_SB(sb);
|
||||
@@ -1404,7 +1404,7 @@ static int isofs_read_inode(struct inode *inode)
|
||||
*/
|
||||
|
||||
if (!high_sierra) {
|
||||
parse_rock_ridge_inode(de, inode);
|
||||
parse_rock_ridge_inode(de, inode, relocated);
|
||||
/* if we want uid/gid set, override the rock ridge setting */
|
||||
if (sbi->s_uid_set)
|
||||
inode->i_uid = sbi->s_uid;
|
||||
@@ -1483,9 +1483,10 @@ static int isofs_iget5_set(struct inode *ino, void *data)
|
||||
* offset that point to the underlying meta-data for the inode. The
|
||||
* code below is otherwise similar to the iget() code in
|
||||
* include/linux/fs.h */
|
||||
struct inode *isofs_iget(struct super_block *sb,
|
||||
unsigned long block,
|
||||
unsigned long offset)
|
||||
struct inode *__isofs_iget(struct super_block *sb,
|
||||
unsigned long block,
|
||||
unsigned long offset,
|
||||
int relocated)
|
||||
{
|
||||
unsigned long hashval;
|
||||
struct inode *inode;
|
||||
@@ -1507,7 +1508,7 @@ struct inode *isofs_iget(struct super_block *sb,
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
if (inode->i_state & I_NEW) {
|
||||
ret = isofs_read_inode(inode);
|
||||
ret = isofs_read_inode(inode, relocated);
|
||||
if (ret < 0) {
|
||||
iget_failed(inode);
|
||||
inode = ERR_PTR(ret);
|
||||
|
Reference in New Issue
Block a user