diskfilter: don't make a RAID array with more than 1024 disks
PATCH 1/1 diskfilter: don't make a RAID array with more than 1024 disks
This is 'belt and braces' with commit 12e20a6a695f ("disk/diskfilter:
Check calloc() result for NULL"): we end up trying to use too much memory in situations like corrupted Linux software raid setups purporting to use a huge number of disks. Simply refuse to permit such configurations.
1024 is a bit arbitrary, yes, and I feel a bit like I'm tempting fate here, but I think 1024 disks in an array (that grub has to read to boot!) should be enough for anyone.
---
v2: add a minimum of 1 disk as nmemb is a signed integer.
Tested with ./grub-fs-tester using mdraid12_raid1 and mdraid12_raid5. Hopefully that means things work; I don't have software raid set up locally.
--- grub-core/disk/diskfilter.c | 7 +++++++ 1 file changed, 7 insertions(+)
grub-core/disk/diskfilter.c +7 -0
@@ -1046,6 +1046,13 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,struct grub_diskfilter_pv *pv;grub_err_t err; +/* We choose not to support more than 1024 disks */ +if (nmemb <1 || nmemb >1024 ) + { +grub_free (uuid); +return NULL ; + } +switch (level) {case 1 :
Signature · 1 line
2.25.1
Quoted 10 lines · Daniel Axtens
This is 'belt and braces' with commit
12e20a6a695f("disk/diskfilter:
Checkcalloc()result for NULL"): we end up trying to use too much memory in situations like corrupted Linux software raid setups purporting to use a huge number of disks. Simply refuse to permit such configurations.1024 is a bit arbitrary, yes, and I feel a bit like I'm tempting fate here, but I think 1024 disks in an array (that grub has to read to boot!) should be enough for anyone.
Signed-off-by Daniel Axtens <[email protected]>
Daniel