-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Am Sat, 16 Jun 2018 15:16:03 +0000 (UTC) Allan Jude <allanj...@freebsd.org> schrieb:
> Author: allanjude > Date: Sat Jun 16 15:16:02 2018 > New Revision: 335254 > URL: https://svnweb.freebsd.org/changeset/base/335254 > > Log: > Avoid reading past the end of the disk in zfsboot.c and biosdisk.c > > The GELI boot code rounds reads up to 4k, since the encrypted sectors are > 4k, and must be decrypted as a unit. With oddball sized disks (almost > always virtual), this can lead to reading past the end of the disk. > > Reviewed by: imp, tsoome > Sponsored by: Klara Systems > Differential Revision: https://reviews.freebsd.org/D15844 > > Modified: > head/stand/i386/libi386/biosdisk.c > head/stand/i386/zfsboot/zfsboot.c > > Modified: head/stand/i386/libi386/biosdisk.c > ============================================================================== > --- head/stand/i386/libi386/biosdisk.c Sat Jun 16 15:05:05 2018 > (r335253) > +++ head/stand/i386/libi386/biosdisk.c Sat Jun 16 15:16:02 2018 > (r335254) > @@ -882,6 +882,12 @@ bd_read(struct disk_devdesc *dev, daddr_t dblk, int bl > } > } > > + if (alignlba + alignblks > BD(dev).bd_sectors) { > + DEBUG("Shorted read at %llu from %d to %llu blocks", > + alignlba, alignblks, BD(dev).bd_sectors - alignlba); > + alignblks = BD(dev).bd_sectors - alignlba; > + } > + > err = bd_io(dev, alignlba, alignblks, tmpbuf, 0); > if (err) > return (err); > > Modified: head/stand/i386/zfsboot/zfsboot.c > ============================================================================== > --- head/stand/i386/zfsboot/zfsboot.c Sat Jun 16 15:05:05 2018 > (r335253) > +++ head/stand/i386/zfsboot/zfsboot.c Sat Jun 16 15:16:02 2018 > (r335254) > @@ -209,6 +209,12 @@ vdev_read(void *xvdev, void *priv, off_t off, void *bu > alignnb = roundup2(nb * DEV_BSIZE + diff, DEV_GELIBOOT_BSIZE) > / DEV_BSIZE; > > + if (dsk->size > 0 && alignlba + alignnb > dsk->size + > dsk->start) { > + printf("Shortening read at %lld from %d to %lld\n", > alignlba, > + alignnb, (dsk->size + dsk->start) - alignlba); > + alignnb = (dsk->size + dsk->start) - alignlba; > + } > + > if (drvread(dsk, dmadat->rdbuf, alignlba, alignnb)) > return -1; > #ifdef LOADER_GELI_SUPPORT > @@ -694,7 +700,7 @@ main(void) > dsk->slice = *(uint8_t *)PTOV(ARGS + 1) + 1; > dsk->part = 0; > dsk->start = 0; > - dsk->size = 0; > + dsk->size = drvsize_ext(dsk); > > bootinfo.bi_version = BOOTINFO_VERSION; > bootinfo.bi_size = sizeof(bootinfo); > @@ -745,7 +751,7 @@ main(void) > dsk->slice = 0; > dsk->part = 0; > dsk->start = 0; > - dsk->size = 0; > + dsk->size = drvsize_ext(dsk); > probe_drive(dsk); > } > > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org" Hello Allan, are there any chances that these changes to "stand" have influences (in a bad way) booting off AMD64 GPT/MBR disks? I realised that CURRENT r335222 from Friday, 10th June 2018 booted without problems (NanoBSD, slightly modified to boot off GPT/UEFI partitions, but in general a simple "gpart bootcode -b pmbr -p /boot/gptboot -i 2 mmcsd0" preparation of a dd'd image). Another try with recent r335282 on a APU 2C4, freshly build NanoBSD, fails to boot firststage: the (most recent) SEABios stopps for ever at telling "Booting from hard disk"; were usually a carret starts to spinn there is vast emptyness. Preparing the boot partition with an older bootcode on that very same SD card via "gpart bootcode -b pmbr - -p /boot/gptboot -i 2 mmcsd0" with an older booted image of CURRENT has solved the problem. The layout of the SD card is as follows, just for the record: #: gpart show mmcsd0 => 40 60751792 mmcsd0 GPT (29G) 40 1024 2 freebsd-boot (512K) 1064 2205944 3 freebsd-ufs (1.1G) 2207008 2210127 4 freebsd-ufs (1.1G) 4417135 1048576 5 freebsd-ufs (512M) 5465711 55286121 - free - (26G) Kind regards, oh - -- O. Hartmann Ich widerspreche der Nutzung oder Übermittlung meiner Daten für Werbezwecke oder für die Markt- oder Meinungsforschung (§ 28 Abs. 4 BDSG). -----BEGIN PGP SIGNATURE----- iLUEARMKAB0WIQQZVZMzAtwC2T/86TrS528fyFhYlAUCWyZADgAKCRDS528fyFhY lIQNAfwOt0In9GkuIamrlvLOpyXJas4h0soqv/39GQYrmeP7eB1+c4fTdmIbBtsG LQH6715pdXc/AO8Ra6JOygu8lzniAgCFaufuLGIHAamNXD60GvpeRLrxVUdR6H14 Rq5k9hsrAzkH0mO0UGPrjwn6RXXS+7cIHa0hYT1GgXF2VtqrNDcS =8uo4 -----END PGP SIGNATURE----- _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"