HomeFreeBSD

geom_part: Check number of GPT entries and size of GPT entry

Description

geom_part: Check number of GPT entries and size of GPT entry

Current specification does not have upper limit of the number of
partition entries and the size of partition entry. In
799eac8c3df597179bbb3b078362f3ff03993a1a Andrey V. Elsukov introduced a
limit maximum number of GPT entries to 4k, but that is for write routine
(gpart create) only. When attaching disks that have large number of GPT
entries exceeding the limit, or disks with large size of partition
entry, it is still possible to exhaust kernel memory.

  1. Reuse the limit of the maximum number of partition entries.
  2. Limit the maximum size of GPT entry to 1k.

In current specification (2.10) the size of GPT entry is 128 *
2^n while n >= 0, and the size - 128 is reserved. 1k should be
sufficient enough for foreseen future.

PR: 266548
Discussed with: imp
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D36717

(cherry picked from commit 5be5d0d5cb2657d7668f4ca0f8543198cf8d759b)

Details

Provenance
zleiAuthored on Oct 18 2022, 3:03 PM
markjCommitted on Nov 21 2022, 1:49 PM
Reviewer
markj
Differential Revision
D36717: geom_part: Check number of GPT entries and size of GPT entry
Parents
rG055648ccb721: bhyve: Simplify control flow in the xhci device model
Branches
Unknown
Tags
Unknown