mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 00:03:29 +03:00
fix(storage): reject unusable erasure metadata at every sink
Malformed erasure layouts can divide by zero, while negative part sizes collapse expected shard sizes to zero and make truncated data appear healthy. Boundary validation alone is insufficient because poisoned metadata may already exist on disk or arrive through local heal paths. Reject non-positive block sizes at the sole Erasure constructor, guard the metadata arithmetic helpers and rebalance calculation, refuse negative part sizes before persistence, and make CheckParts and VerifyFile reject previously stored poison. Tests cover both shard-size implementations, construction, persistence, local verification, and the wire boundary. Co-authored-by: ChatGPT <noreply@openai.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,11 @@ func (rs *rebalanceStats) update(bucket string, fi FileInfo) {
|
||||
|
||||
rs.NumVersions++
|
||||
onDiskSz := int64(0)
|
||||
if !fi.Deleted {
|
||||
// DataBlocks comes from xl.meta and only fi.Deleted is checked above, so a
|
||||
// zero here is an integer divide-by-zero rather than a bad statistic. This
|
||||
// path does not build an Erasure, so NewErasure's validation does not cover
|
||||
// it; leave the size at zero for metadata that cannot describe a layout.
|
||||
if !fi.Deleted && fi.Erasure.DataBlocks > 0 {
|
||||
onDiskSz = fi.Size * int64(fi.Erasure.DataBlocks+fi.Erasure.ParityBlocks) / int64(fi.Erasure.DataBlocks)
|
||||
}
|
||||
rs.Bytes += uint64(onDiskSz)
|
||||
|
||||
Reference in New Issue
Block a user