mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
isofs: fix Rock Ridge CE extent validation on multisession media
Commita36d990f59("isofs: validate Rock Ridge CE continuation extent against volume size") compares the CE extent directly with s_nzones. The extent is an absolute block number, while s_nzones is the number of blocks relative to the selected ISO session. The comparison is therefore wrong when a multisession disc starts at a non-zero block. isofs_get_last_session() selects the last session on multisession media, and its volume descriptors describe a volume beginning at that session's LBA. For example, a session beginning at LBA 45447 with 64 blocks can contain a valid CE at absolute LBA 45467. The existing check rejects that CE, so the ER continuation record is not read, Rock Ridge is disabled, and the mount falls back to Joliet names. Save the selected session start in filesystem-block units and validate the CE extent against the half-open interval [session_start, session_end). Scale the session length to the same block units and retain a separate block-device limit. The lower bound is intentional: accepting arbitrary blocks before the selected session could make a CE read data from a previous session or another filesystem on the device. Only apply the bounds check when cont_extent is non-zero. A zero extent is the in-memory sentinel indicating that no CE continuation was found, rather than a request to read block zero. For a single-session image, session_start is zero and the effective volume boundary remains unchanged. Build-tested with: make CONFIG_RUST= CONFIG_RUST_DRIVERS= fs/isofs/ Fixes:a36d990f59("isofs: validate Rock Ridge CE continuation extent against volume size") Cc: stable@vger.kernel.org Signed-off-by: Baolin Liu <liubaolin@kylinos.cn> Link: https://patch.msgid.link/20260907082602.3777551-1-liubaolin12138@163.com Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
9e1483cf2d
commit
43de050fa4
|
|
@ -821,6 +821,8 @@ static int isofs_fill_super(struct super_block *s, struct fs_context *fc)
|
|||
if (!sb_set_blocksize(s, orig_zonesize))
|
||||
goto out_freesbi;
|
||||
|
||||
sbi->s_session_start = (sector_t)vol_desc_start <<
|
||||
(ISOFS_BLOCK_BITS - s->s_blocksize_bits);
|
||||
sbi->s_nls_iocharset = NULL;
|
||||
|
||||
#ifdef CONFIG_JOLIET
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ struct isofs_sb_info {
|
|||
unsigned long s_firstdatazone;
|
||||
unsigned long s_log_zone_size;
|
||||
unsigned long s_max_size;
|
||||
/* Session start in filesystem block units. */
|
||||
sector_t s_session_start;
|
||||
|
||||
int s_rock_offset; /* offset of SUSP fields within SU area */
|
||||
s32 s_sbsector;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/blkdev.h>
|
||||
|
||||
#include "isofs.h"
|
||||
#include "rock.h"
|
||||
|
|
@ -84,6 +85,10 @@ static void init_rock_state(struct rock_state *rs, struct inode *inode)
|
|||
*/
|
||||
static int rock_continue(struct rock_state *rs)
|
||||
{
|
||||
struct super_block *sb = rs->inode->i_sb;
|
||||
struct isofs_sb_info *sbi = ISOFS_SB(sb);
|
||||
sector_t session_end = sbi->s_session_start +
|
||||
((sector_t)sbi->s_nzones << (ISOFS_BLOCK_BITS - sb->s_blocksize_bits));
|
||||
int ret = 1;
|
||||
int blocksize = 1 << rs->inode->i_blkbits;
|
||||
const int min_de_size = offsetof(struct rock_ridge, u);
|
||||
|
|
@ -101,11 +106,13 @@ static int rock_continue(struct rock_state *rs)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if ((unsigned)rs->cont_extent >= ISOFS_SB(rs->inode->i_sb)->s_nzones) {
|
||||
if (rs->cont_extent &&
|
||||
(rs->cont_extent < sbi->s_session_start ||
|
||||
rs->cont_extent >= session_end)) {
|
||||
printk(KERN_NOTICE "rock: corrupted directory entry. "
|
||||
"extent=%u out of volume (nzones=%lu)\n",
|
||||
(unsigned)rs->cont_extent,
|
||||
ISOFS_SB(rs->inode->i_sb)->s_nzones);
|
||||
sbi->s_nzones);
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user