Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Oct 2018 16:39:23 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 231881] boot0cfg can not configutr "version 1.0" boot0 due to bug in gpart_mbr bootcode
Message-ID:  <bug-231881-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D231881

            Bug ID: 231881
           Summary: boot0cfg can not configutr "version 1.0" boot0 due to
                    bug in gpart_mbr bootcode
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: lev@FreeBSD.org

boot0/boot0sio have disk serial number compiled-in by default. It is named
"version 2" boot block by boot0cfg(8) and this format places 4 byte Disk Se=
rial
Number where "version 1" boot block contains options.

Support for disk serial number in boot0/boot0sio is optional, and could be
turned off to save some bytes, needed for other options.

boot0cfg(8) properly supports old placement of boot block options, properly
detect boot block without disk serial number support and properly prepare
options for it.

Problem is, boot0cfg(8) uses "gpart bootcode" command to wriet boot block w=
ith
new options back to disk.

And gmart_mbr always try to save disk serial number, which kills options if
boot block is "version 1":

static int
g_part_mbr_bootcode(struct g_part_table *basetable, struct g_part_parms *gp=
p)
{
        struct g_part_mbr_table *table;
        uint32_t dsn;

        if (gpp->gpp_codesize !=3D MBRSIZE)
                return (ENODEV);

        table =3D (struct g_part_mbr_table *)basetable;
        dsn =3D *(uint32_t *)(table->mbr + DOSDSNOFF);
        bcopy(gpp->gpp_codeptr, table->mbr, DOSPARTOFF);
        if (dsn !=3D 0)
                *(uint32_t *)(table->mbr + DOSDSNOFF) =3D dsn;
        return (0);
}

Sometimes, it leads to complete bogus options written which kill boot0/boot=
0sio
(it have invalid slice mask, for example, and is unable to boot at all) and
sometimes it simply didn't give user ability to change boot0/boot0sio optio=
ns.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



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