Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Mar 2019 03:10:24 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r345434 - stable/11/sys/geom/part
Message-ID:  <201903230310.x2N3AO1I058700@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sat Mar 23 03:10:23 2019
New Revision: 345434
URL: https://svnweb.freebsd.org/changeset/base/345434

Log:
  MFC 344790:
  
  Revert revision 254095
  
  In revision 254095, gpt_entries is not set to match the on-disk
  hdr_entries, but rather is computed based on available space.
  There are 2 problems with this:
  
  1.  The GPT backend respects hdr_entries and only reads and writes
      that number of partition entries.  On top of that, CRC32 is
      computed over the table that has hdr_entries elements.  When
      the common code works on what is possibly a larger number, the
      behaviour becomes inconsistent and problematic.  In particular,
      it would be possible to add a new partition that on a reboot
      isn't there anymore.
  2.  The calculation of gpt_entries is based on flawed assumptions.
      The GPT specification does not dictate that sectors are layed
      out in a particular way that the available space can be
      determined by looking at LBAs.  In practice, implementations
      do the same thing, because there's no reason to do it any
      other way.  Still, GPT allows certain freedoms that can be
      exploited in some form or shape if the need arises.
  
  PR:		229977
  Differential Revision:	https://reviews.freebsd.org/D19438

Modified:
  stable/11/sys/geom/part/g_part_gpt.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/geom/part/g_part_gpt.c
==============================================================================
--- stable/11/sys/geom/part/g_part_gpt.c	Sat Mar 23 02:53:47 2019	(r345433)
+++ stable/11/sys/geom/part/g_part_gpt.c	Sat Mar 23 03:10:23 2019	(r345434)
@@ -978,10 +978,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct
 
 	basetable->gpt_first = table->hdr->hdr_lba_start;
 	basetable->gpt_last = table->hdr->hdr_lba_end;
-	basetable->gpt_entries = (table->hdr->hdr_lba_start - 2) *
-	    pp->sectorsize / table->hdr->hdr_entsz;
+	basetable->gpt_entries = table->hdr->hdr_entries;
 
-	for (index = table->hdr->hdr_entries - 1; index >= 0; index--) {
+	for (index = basetable->gpt_entries - 1; index >= 0; index--) {
 		if (EQUUID(&tbl[index].ent_type, &gpt_uuid_unused))
 			continue;
 		entry = (struct g_part_gpt_entry *)g_part_new_entry(



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903230310.x2N3AO1I058700>