git: DragonFly_RELEASE_6_4 kernel: Fix two bugs in gptinit()

Aaron LI aly at crater.dragonflybsd.org
Tue Sep 1 22:49:07 PDT 2026


commit d0146925e83b58154a5c70bfba689041aefbf43b
Author: Aaron LI <aly at aaronly.me>
Date:   Wed Aug 26 00:00:19 2026 +0800

    kernel: Fix two bugs in gptinit()
    
    * Fix the wrong type for 'table_lba'; should be 'uint64_t' instead of
      'uint32_t', and fix the read to use le64toh().
    
    * Allow the partition table has entries more than 128 (MAX_GPT_ENTRIES).
      The UEFI specification basically has no upper limit, but we limit to
      parsing the first 128 (MAX_GPT_ENTRIES) entries.
    
      This actually happens with a Proxmox v9.2 ISO, which uses GPT and
      allocates 44 blocks for the partition table, so there are 176 entries.
    
      For example, here is the gpt(8) of a USB stick written with this ISO:
    
      ```
      Disk da8: 57.3GB (120225792 512-byte sectors)
          Start    Sectors    Size  Index  Contents
              0          1    512B      -  PMBR
              1          1    512B      -  Primary GPT header
              2         18   9216B      -  Unused
             20         44  22.0KB      -  Primary GPT table
             64        560   280KB      0  GPT part - MS Basic Data
            624      16384  8192KB      1  GPT part - EFI System
          17008    3314724  1619MB      2  GPT part - Apple HFS+
        3331732        600   300KB      3  GPT part - MS Basic Data
        3332332          3   1536B      -  Unused
        3332335         44  22.0KB      -  Secondary GPT table
        3332379          1    512B      -  Secondary GPT header
        3332380  116893412  55.7GB      -  Unused
      ```
    
    Reported-by: swildner

Summary of changes:
 sys/kern/subr_diskgpt.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/d0146925e83b58154a5c70bfba689041aefbf43b


-- 
DragonFly BSD source repository


More information about the Commits mailing list