aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/geom/part/g_part.c9
-rw-r--r--sys/geom/part/g_part_gpt.c7
2 files changed, 10 insertions, 6 deletions
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c
index c969b9e7cc64..8b79b6404a6d 100644
--- a/sys/geom/part/g_part.c
+++ b/sys/geom/part/g_part.c
@@ -135,9 +135,9 @@ struct g_part_alias_list {
SYSCTL_DECL(_kern_geom);
SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0,
"GEOM_PART stuff");
-static u_int check_integrity = 1;
+u_int geom_part_check_integrity = 1;
SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity,
- CTLFLAG_RWTUN, &check_integrity, 1,
+ CTLFLAG_RWTUN, &geom_part_check_integrity, 1,
"Enable integrity checking");
static u_int auto_resize = 1;
SYSCTL_UINT(_kern_geom_part, OID_AUTO, auto_resize,
@@ -420,7 +420,7 @@ g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp)
if (failed != 0) {
printf("GEOM_PART: integrity check failed (%s, %s)\n",
pp->name, table->gpt_scheme->name);
- if (check_integrity != 0)
+ if (geom_part_check_integrity != 0)
return (EINVAL);
table->gpt_corrupt = 1;
}
@@ -1846,7 +1846,8 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
table = gpp.gpp_geom->softc;
if (table != NULL && table->gpt_corrupt &&
ctlreq != G_PART_CTL_DESTROY &&
- ctlreq != G_PART_CTL_RECOVER) {
+ ctlreq != G_PART_CTL_RECOVER &&
+ geom_part_check_integrity) {
gctl_error(req, "%d table '%s' is corrupt",
EPERM, gpp.gpp_geom->name);
return;
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c
index a17cb30ea806..8fd3b490c4fc 100644
--- a/sys/geom/part/g_part_gpt.c
+++ b/sys/geom/part/g_part_gpt.c
@@ -64,6 +64,8 @@ SYSCTL_UINT(_kern_geom_part_gpt, OID_AUTO, allow_nesting,
CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
CTASSERT(sizeof(struct gpt_ent) == 128);
+extern u_int geom_part_check_integrity;
+
#define EQUUID(a,b) (memcmp(a, b, sizeof(struct uuid)) == 0)
#define MBRSIZE 512
@@ -460,8 +462,9 @@ gpt_read_hdr(struct g_part_gpt_table *table, struct g_consumer *cp,
if (hdr->hdr_lba_self != table->lba[elt])
goto fail;
hdr->hdr_lba_alt = le64toh(buf->hdr_lba_alt);
- if (hdr->hdr_lba_alt == hdr->hdr_lba_self ||
- hdr->hdr_lba_alt > last)
+ if (hdr->hdr_lba_alt == hdr->hdr_lba_self)
+ goto fail;
+ if (hdr->hdr_lba_alt > last && geom_part_check_integrity)
goto fail;
/* Check the managed area. */