We overallocate by quite a bit for bootable disks;  spotted while
reading the code and tested by installboot(8)ing onto vnd(4) backed
softraid disks (after booting a kernel with this diff).

        $ egdb --quiet obj/bsd.gdb
        Reading symbols from obj/bsd.gdb...done.
        (gdb) p sizeof(struct sr_meta_crypto)
        $1 = 2480
        (gdb) p sizeof(struct sr_meta_boot)
        $2 = 168

Feedback? OK?

Index: sys/dev/softraid.c
===================================================================
RCS file: /cvs/src/sys/dev/softraid.c,v
retrieving revision 1.405
diff -u -p -r1.405 softraid.c
--- sys/dev/softraid.c  27 Jun 2020 17:28:58 -0000      1.405
+++ sys/dev/softraid.c  12 Jul 2020 17:59:56 -0000
@@ -3736,7 +3736,7 @@ sr_ioctl_installboot(struct sr_softc *sc
        if (omi == NULL) {
                omi = malloc(sizeof(struct sr_meta_opt_item), M_DEVBUF,
                    M_WAITOK | M_ZERO);
-               omi->omi_som = malloc(sizeof(struct sr_meta_crypto), M_DEVBUF,
+               omi->omi_som = malloc(sizeof(struct sr_meta_boot), M_DEVBUF,
                    M_WAITOK | M_ZERO);
                omi->omi_som->som_type = SR_OPT_BOOT;
                omi->omi_som->som_length = sizeof(struct sr_meta_boot);

Reply via email to