Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dkwedge Quadruple GPT partition entry count limit (t...



details:   https://anonhg.NetBSD.org/src/rev/e73bedee06d4
branches:  trunk
changeset: 340122:e73bedee06d4
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sun Aug 23 18:40:15 2015 +0000

description:
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.

diffstat:

 sys/dev/dkwedge/dkwedge_gpt.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r 9c1dbd3fcd3f -r e73bedee06d4 sys/dev/dkwedge/dkwedge_gpt.c
--- a/sys/dev/dkwedge/dkwedge_gpt.c     Sun Aug 23 18:33:15 2015 +0000
+++ b/sys/dev/dkwedge/dkwedge_gpt.c     Sun Aug 23 18:40:15 2015 +0000
@@ -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 @@
        }
        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);



Home | Main Index | Thread Index | Old Index