From feabea0f74a8f331b47ca132bf32f2c82e8a283a Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sun, 16 Feb 2014 23:51:16 +0100 Subject: [PATCH] kernel/nataraid: Fix a bug for array sizes >2TB. The overall array size (total_sectors) in the softc was already 64 bit wide but due to a missing cast when multiplying the 32 bit disk size by the number of disks, it never became larger than 32 bits. Also, the disk size was signed when it should have been unsigned. Note that these fixes apply to RAIDs created using natacontrol(8), but not necessarily to those created with BIOS utilities. Reported-by: Aaron Bieber --- sys/dev/disk/nata/ata-raid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/disk/nata/ata-raid.c b/sys/dev/disk/nata/ata-raid.c index 9137e777af..33fc7e249a 100644 --- a/sys/dev/disk/nata/ata-raid.c +++ b/sys/dev/disk/nata/ata-raid.c @@ -1029,7 +1029,8 @@ ata_raid_create(struct ata_ioc_raid_config *config) struct ar_softc *rdp; device_t subdisk; int array, disk; - int ctlr = 0, disk_size = 0, total_disks = 0; + int ctlr = 0, total_disks = 0; + u_int disk_size = 0; device_t gpdev; for (array = 0; array < MAX_ARRAYS; array++) { @@ -1249,7 +1250,8 @@ ata_raid_create(struct ata_ioc_raid_config *config) rdp->total_disks = total_disks; rdp->width = total_disks / (rdp->type & (AR_RAID1 | AR_T_RAID01) ? 2 : 1); - rdp->total_sectors = disk_size * (rdp->width - (rdp->type == AR_RAID5)); + rdp->total_sectors = + (uint64_t)disk_size * (rdp->width - (rdp->type == AR_RAID5)); rdp->heads = 255; rdp->sectors = 63; rdp->cylinders = rdp->total_sectors / (255 * 63); -- 2.41.0