Commit 5cdc4a69 authored by lianzhi chang's avatar lianzhi chang Committed by Jan Kara

udf: fix the problem that the disc content is not displayed

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.comSigned-off-by: default avatarlianzhi chang <changlianzhi@uniontech.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 1e249cb5
...@@ -705,6 +705,7 @@ static int udf_check_vsd(struct super_block *sb) ...@@ -705,6 +705,7 @@ static int udf_check_vsd(struct super_block *sb)
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
int nsr = 0; int nsr = 0;
struct udf_sb_info *sbi; struct udf_sb_info *sbi;
loff_t session_offset;
sbi = UDF_SB(sb); sbi = UDF_SB(sb);
if (sb->s_blocksize < sizeof(struct volStructDesc)) if (sb->s_blocksize < sizeof(struct volStructDesc))
...@@ -712,7 +713,8 @@ static int udf_check_vsd(struct super_block *sb) ...@@ -712,7 +713,8 @@ static int udf_check_vsd(struct super_block *sb)
else else
sectorsize = sb->s_blocksize; sectorsize = sb->s_blocksize;
sector += (((loff_t)sbi->s_session) << sb->s_blocksize_bits); session_offset = (loff_t)sbi->s_session << sb->s_blocksize_bits;
sector += session_offset;
udf_debug("Starting at sector %u (%lu byte sectors)\n", udf_debug("Starting at sector %u (%lu byte sectors)\n",
(unsigned int)(sector >> sb->s_blocksize_bits), (unsigned int)(sector >> sb->s_blocksize_bits),
...@@ -757,8 +759,7 @@ static int udf_check_vsd(struct super_block *sb) ...@@ -757,8 +759,7 @@ static int udf_check_vsd(struct super_block *sb)
if (nsr > 0) if (nsr > 0)
return 1; return 1;
else if (!bh && sector - (sbi->s_session << sb->s_blocksize_bits) == else if (!bh && sector - session_offset == VSD_FIRST_SECTOR_OFFSET)
VSD_FIRST_SECTOR_OFFSET)
return -1; return -1;
else else
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment