Skip to content

Commit a9fd4ef

Browse files
lianzhi changgregkh
authored andcommitted
udf: fix the problem that the disc content is not displayed
[ Upstream commit 5cdc4a6 ] When the capacity of the disc is too large (assuming the 4.7G specification), the disc (UDF file system) will be burned multiple times in the windows (Multisession Usage). When the remaining capacity of the CD is less than 300M (estimated value, for reference only), open the CD in the Linux system, the content of the CD is displayed as blank (the kernel will say "No VRS found"). Windows can display the contents of the CD normally. Through analysis, in the "fs/udf/super.c": udf_check_vsd function, the actual value of VSD_MAX_SECTOR_OFFSET may be much larger than 0x800000. According to the current code logic, it is found that the type of sbi->s_session is "__s32", when the remaining capacity of the disc is less than 300M (take a set of test values: sector=3154903040, sbi->s_session=1540464, sb->s_blocksize_bits=11 ), the calculation result of "sbi->s_session << sb->s_blocksize_bits" will overflow. Therefore, it is necessary to convert the type of s_session to "loff_t" (when udf_check_vsd starts, assign a value to _sector, which is also converted in this way), so that the result will not overflow, and then the content of the disc can be displayed normally. Link: https://lore.kernel.org/r/20210114075741.30448-1-changlianzhi@uniontech.com Signed-off-by: lianzhi chang <changlianzhi@uniontech.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 40545c4 commit a9fd4ef

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/udf/super.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,16 @@ static int udf_check_vsd(struct super_block *sb)
705705
struct buffer_head *bh = NULL;
706706
int nsr = 0;
707707
struct udf_sb_info *sbi;
708+
loff_t session_offset;
708709

709710
sbi = UDF_SB(sb);
710711
if (sb->s_blocksize < sizeof(struct volStructDesc))
711712
sectorsize = sizeof(struct volStructDesc);
712713
else
713714
sectorsize = sb->s_blocksize;
714715

715-
sector += (((loff_t)sbi->s_session) << sb->s_blocksize_bits);
716+
session_offset = (loff_t)sbi->s_session << sb->s_blocksize_bits;
717+
sector += session_offset;
716718

717719
udf_debug("Starting at sector %u (%lu byte sectors)\n",
718720
(unsigned int)(sector >> sb->s_blocksize_bits),
@@ -757,8 +759,7 @@ static int udf_check_vsd(struct super_block *sb)
757759

758760
if (nsr > 0)
759761
return 1;
760-
else if (!bh && sector - (sbi->s_session << sb->s_blocksize_bits) ==
761-
VSD_FIRST_SECTOR_OFFSET)
762+
else if (!bh && sector - session_offset == VSD_FIRST_SECTOR_OFFSET)
762763
return -1;
763764
else
764765
return 0;

0 commit comments

Comments
 (0)