HomeFreeBSD

g_part_bsd64: Check for valid on-disk npartitions value

Description

g_part_bsd64: Check for valid on-disk npartitions value

This value is u32 on disk, but assigned to an int in memory. After we do the
implicit conversion via assignment, check that the result is at least one[1]
(non-negative[2]).

  1. The subsequent for-loop iterates from gpt_entries minus one, down, until reaching zero. A negative or zero initial index results in undefined signed integer overflow.
  2. It is also used to index into arrays later.

In practice, we expected non-malicious disks to contain small positive values.

Reported by: Coverity
CID: 1223202
Sponsored by: EMC / Isilon Storage Division

Details

Provenance
cemAuthored on
Parents
rS298670: ciss(4): Fix overrun of array
Branches
Unknown
Tags
Unknown