Quadruple GPT partition entry count limit (to 512 entries or 64KiB).
The UEFI 2.3.1 specification states that: "A minimum of 16,384 bytes of space must be reserved for the GPT Partition Entry Array." and [the size of a partition entry shall be a power of two greater than 128] and that [the defined fields of a partition entry total 128 bytes]. Clamping the entries means that no partitions on the drive will be detected, as this will result in an incorrect partition entry array CRC. This change reduces the likelyhood of useless partitions, while still not allowing a huge kernel memory allocation to load the partition entries into. In the future this code should probably be reworked to checksum and evaluate the partition array in chunks while still limiting the number of GPT wedges added per drive to something reasonable.
This commit is contained in:
parent
ef363e2dc9
commit
45dc116cb7
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dkwedge_gpt.c,v 1.14 2014/11/04 07:43:00 mlelstv Exp $ */
|
||||
/* $NetBSD: dkwedge_gpt.c,v 1.15 2015/08/23 18:40:15 jakllsch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.14 2014/11/04 07:43:00 mlelstv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.15 2015/08/23 18:40:15 jakllsch Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -178,11 +178,11 @@ dkwedge_discover_gpt(struct disk *pdk, struct vnode *vp)
|
|||
}
|
||||
gpe_crc = le32toh(hdr->hdr_crc_table);
|
||||
|
||||
/* XXX Clamp entries at 128 for now. */
|
||||
if (entries > 128) {
|
||||
/* XXX Clamp entries at 512 for now. */
|
||||
if (entries > 512) {
|
||||
aprint_error("%s: WARNING: clamping number of GPT entries to "
|
||||
"128 (was %u)\n", pdk->dk_name, entries);
|
||||
entries = 128;
|
||||
"512 (was %u)\n", pdk->dk_name, entries);
|
||||
entries = 512;
|
||||
}
|
||||
|
||||
lba_start = le64toh(hdr->hdr_lba_start);
|
||||
|
|
Loading…
Reference in New Issue