[PATCH v2 0/3] udf: Fix some signed/unsigned conversion issues
From: Steve Magnani
Date: Thu Oct 12 2017 - 09:49:34 EST
The UDF driver has several points at which conversion between unsigned and
signed types cause (or could cause) problems. On 64-bit systems,
conversion of block addresses larger than 0x7FFFFFFF (>= 1 TiB when
blocksize is 512 bytes) can involve undesired sign extension that corrupts
the block address value. This is known to cause the following problems:
* readdir() can fail on a directory containing File Identifiers residing
above 0x7FFFFFFF. This manifests as a 'ls' command failing with EIO.
* FIBMAP on a file block located above 0x7FFFFFFF can return a negative
value. The low 32 bits are correct, but applications that don't mask the
high 32 bits of the result can perform incorrectly.
Additionally, large unsigned values can be printed as negative numbers,
for example:
Partition (0 type 1511) starts at physical 460, block length -1779968542
Take care to use unsigned types to store UDF block addresses and to use
format specifiers that match the signedness of the values they are to
print.
Changes since V1:
* Separated printing fixes from sign extension fixes
* Implemented suggested udf_pblk_t typedef for representation of
block addresses and use it in place of 'uint32_t' for changes in this
patch series
* Converted some uint32_t block address variables in inode_getblk() to
udf_pblk_t
* Fixed additional signed/unsigned type mismatches in:
- udf_table_new_block()
- udf_fileident_read()
- udf_new_inode()
- udf_split_extents()
- udf_getblk()
- udf_do_extend_file()
- udf_bread()
- udf_setsize()
- udf_setup_indirect_aext()
- udf_add_aext()
- extent_trunc()
Signed-off-by: Steven J. Magnani <steve@xxxxxxxxxxxxxxx>