• Alden Tondettar's avatar
    udf: Use correct partition reference number for metadata · 7888824b
    Alden Tondettar authored
    UDF/OSTA terminology is confusing. Partition Numbers (PNs) are arbitrary
    16-bit values, one for each physical partition in the volume.  Partition
    Reference Numbers (PRNs) are indices into the the Partition Map Table
    and do not necessarily equal the PN of the mapped partition.
    
    The current metadata code mistakenly uses the PN instead of the PRN when
    mapping metadata blocks to physical/sparable blocks.  Windows-created
    UDF 2.5 discs for some reason use large, arbitrary PNs, resulting in
    mount failure and KASAN read warnings in udf_read_inode().
    
    For example, a NetBSD UDF 2.5 partition might look like this:
    
    PRN PN Type
    --- -- ----
      0  0 Sparable
      1  0 Metadata
    
    Since PRN == PN, we are fine.
    
    But Windows could gives us:
    
    PRN PN   Type
    --- ---- ----
      0 8192 Sparable
      1 8192 Metadata
    
    So udf_read_inode() will start out by checking the partition length in
    sbi->s_partmaps[8192], which is obviously out of bounds.
    
    Fix this by creating a new field (s_phys_partition_ref) in struct
    udf_meta_data, referencing whatever physical or sparable map has the
    same partition number as the metadata partition.
    
    [JK: Add comment about s_phys_partition_ref, change its name]
    Signed-off-by: default avatarAlden Tondettar <alden.tondettar@gmail.com>
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    7888824b
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
balloc.c Loading commit data...
dir.c Loading commit data...
directory.c Loading commit data...
ecma_167.h Loading commit data...
file.c Loading commit data...
ialloc.c Loading commit data...
inode.c Loading commit data...
lowlevel.c Loading commit data...
misc.c Loading commit data...
namei.c Loading commit data...
osta_udf.h Loading commit data...
partition.c Loading commit data...
super.c Loading commit data...
symlink.c Loading commit data...
truncate.c Loading commit data...
udf_i.h Loading commit data...
udf_sb.h Loading commit data...
udfdecl.h Loading commit data...
udfend.h Loading commit data...
udftime.c Loading commit data...
unicode.c Loading commit data...