[pve-devel] [PATCH installer 4/4] common: enforce even number of disks for ZFS RAID-10

Christoph Heiss c.heiss at proxmox.com
Tue Nov 21 11:45:51 CET 2023


An uneven number of disks otherwise causes a panic due to an
out-of-bounds array access in the loop below.

Reported-by: Fiona Ebner <f.ebner at proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 proxmox-installer-common/src/disk_checks.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/proxmox-installer-common/src/disk_checks.rs b/proxmox-installer-common/src/disk_checks.rs
index bcf2e21..7cbdf19 100644
--- a/proxmox-installer-common/src/disk_checks.rs
+++ b/proxmox-installer-common/src/disk_checks.rs
@@ -81,6 +81,14 @@ pub fn check_zfs_raid_config(level: ZfsRaidLevel, disks: &[Disk]) -> Result<(),
         }
         ZfsRaidLevel::Raid10 => {
             check_raid_min_disks(disks, 4)?;
+
+            if disks.len() % 2 != 0 {
+                return Err(format!(
+                    "Needs an even number of disks, currently selected: {}",
+                    disks.len(),
+                ));
+            }
+
             // Pairs need to have the same size
             for i in (0..disks.len()).step_by(2) {
                 check_mirror_size(&disks[i], &disks[i + 1])?;
-- 
2.42.0






More information about the pve-devel mailing list