Skip to content

udf: Fix some signed/unsigned conversion issues

Steve Magnani lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 2 repliesIn review
  2. v11 patch 3 repliesSuperseded

Changes in v2 from the cover letter

* 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()

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3udf: Fix 64-bit sign extension issues affecting blocks > 0x7FFFFFFFfs/udf/balloc.c fs/udf/dir.c fs/udf/directory.c +7 more+52 -432 replies
2/3udf: Fix signed/unsigned format specifiersfs/udf/balloc.c fs/udf/directory.c fs/udf/inode.c +5 more+47 -470 replies
3/3udf: Fix some sign-conversion warningsfs/udf/directory.c fs/udf/inode.c+4 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] udf: Fix some signed/unsigned conversion issues

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()