isofs: handle CDs with bad root inode but good Joliet root directory
Subsystems (2)
PATCH 1/1 isofs: handle CDs with bad root inode but good Joliet root directory
I have a CD copy of the original Tom Clancy's Ghost Recon game from 2001. The disc mounts without error on Windows, but on Linux mounting fails with the message "isofs_fill_super: get root inode failed". The error originates in isofs_read_inode, which returns -EIO because de_len is 0. The superblock on this disc appears to be intentionally corrupt as a form of copy protection.
When the root inode is unusable, instead of giving up immediately, try to continue with the Joliet file table. This fixes the Ghost Recon CD and probably other copy-protected CDs too.
--- fs/isofs/inode.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
fs/isofs/inode.c +18 -3
@@ -908,8 +908,22 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)* we then decide whether to use the Joliet descriptor. */ inode =isofs_iget (s, sbi->s_firstdatazone,0 ); -if (IS_ERR (inode)) - goto out_no_root; + +/* +* Fix for broken CDs with a corrupt root inode but a correct Joliet +* root directory. +*/ +if (IS_ERR (inode)) { +if (joliet_level) { +printk (KERN_NOTICE +"ISOFS: root inode is unusable. " +"Disabling Rock Ridge and switching to Joliet." ); + sbi->s_rock =0 ; + inode =NULL ; + }else { + goto out_no_root; + } + }/* * Fix for broken CDs with Rock Ridge and empty ISO root directory but
@@ -939,7 +953,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) sbi->s_firstdatazone = first_data_zone;printk (KERN_DEBUG "ISOFS: changing to secondary root\n" ); -iput (inode); +if (inode !=NULL ) +iput (inode); inode =isofs_iget (s, sbi->s_firstdatazone,0 );if (IS_ERR (inode)) goto out_no_root;
Signature · 1 line
2.43.0
Jan Kara
maintainerQuoted 7 lines · Alex Henrie
I have a CD copy of the original Tom Clancy's Ghost Recon game from 2001. The disc mounts without error on Windows, but on Linux mounting fails with the message "
isofs_fill_super: get root inode failed". The error originates inisofs_read_inode, which returns-EIObecausede_lenis 0. The superblock on this disc appears to be intentionally corrupt as a form of copy protection.
Quoted 5 lines
When the root inode is unusable, instead of giving up immediately, try to continue with the Joliet file table. This fixes the Ghost Recon CD and probably other copy-protected CDs too.
Signed-off-by Alex Henrie <[email protected]>
Thanks! I've added the patch to my tree. Just made two minor tweaks on commit:
fs/isofs/inode.c static int isofs_fill_super(struct super_block *s, void *data, int silent) · line 917
Quoted 13 lines
fs/isofs/inode.c +7
-2@@ -908,8 +908,22 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)* we then decide whether to use the Joliet descriptor. */ inode =isofs_iget (s, sbi->s_firstdatazone,0 ); -if (IS_ERR (inode)) - goto out_no_root; + +/* +* Fix for broken CDs with a corrupt root inode but a correct Joliet +* root directory. +*/ +if (IS_ERR (inode)) { +if (joliet_level) {
Here I've added "&& sbi->s_firstdatazone != first_data_zone" to make sure joliet extension has a different inode. Not sure if such media would be valid but even if it was not, we should not crash the kernel (which would happen in that case because we don't expect inode to be NULL).
Quoted 13 lines
fs/isofs/inode.c +9
-0+printk (KERN_NOTICE +"ISOFS: root inode is unusable. " +"Disabling Rock Ridge and switching to Joliet." ); + sbi->s_rock =0 ; + inode =NULL ; + }else { + goto out_no_root; + } + }/* * Fix for broken CDs with Rock Ridge and empty ISO root directory but
fs/isofs/inode.c static int isofs_fill_super(struct super_block *s, void *data, int silent) · line 957
Quoted 6 lines
fs/isofs/inode.c +2
-1@@ -939,7 +953,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) sbi->s_firstdatazone = first_data_zone;printk (KERN_DEBUG "ISOFS: changing to secondary root\n" ); -iput (inode); +if (inode !=NULL ) +iput (inode);
This isn't needed. iput() handles NULL inode just fine.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 47 lines · Jan Kara
Quoted 7 lines · Alex Henrie
I have a CD copy of the original Tom Clancy's Ghost Recon game from 2001. The disc mounts without error on Windows, but on Linux mounting fails with the message "
isofs_fill_super: get root inode failed". The error originates inisofs_read_inode, which returns-EIObecausede_lenis 0. The superblock on this disc appears to be intentionally corrupt as a form of copy protection.Quoted 5 lines
When the root inode is unusable, instead of giving up immediately, try to continue with the Joliet file table. This fixes the Ghost Recon CD and probably other copy-protected CDs too.
Signed-off-by Alex Henrie <[email protected]>Thanks! I've added the patch to my tree. Just made two minor tweaks on commit:
fs/isofs/inode.c static int isofs_fill_super(struct super_block *s, void *data, int silent) · line 917
Quoted 13 lines
fs/isofs/inode.c +7
-2@@ -908,8 +908,22 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)* we then decide whether to use the Joliet descriptor. */ inode =isofs_iget (s, sbi->s_firstdatazone,0 ); -if (IS_ERR (inode)) - goto out_no_root; + +/* +* Fix for broken CDs with a corrupt root inode but a correct Joliet +* root directory. +*/ +if (IS_ERR (inode)) { +if (joliet_level) {Here I've added "&&
sbi->s_firstdatazone!=first_data_zone" to make sure joliet extension has a different inode. Not sure if such media would be valid but even if it was not, we should not crash the kernel (which would happen in that case because we don't expect inode to be NULL).Quoted 10 lines
fs/isofs/inode.c +9
-0+printk (KERN_NOTICE +"ISOFS: root inode is unusable. " +"Disabling Rock Ridge and switching to Joliet." ); + sbi->s_rock =0 ; + inode =NULL ; + }else { + goto out_no_root; + } + }
Quoted 11 lines
fs/isofs/inode.c static int isofs_fill_super(struct super_block *s, void *data, int silent) · line 957
Quoted 9 lines
fs/isofs/inode.c +2
-1/* * Fix for broken CDs with Rock Ridge and empty ISO root directory but @@ -939,7 +953,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) sbi->s_firstdatazone = first_data_zone;printk (KERN_DEBUG "ISOFS: changing to secondary root\n" ); -iput (inode); +if (inode !=NULL ) +iput (inode);This isn't needed.
iput()handles NULL inode just fine.
I tried out your two changes and the patch still works great. Thank you for noticing and fixing those details, and thanks for the quick review!
-Alex