Date: Thu, 19 Mar 2020 17:27:08 +0000 (UTC) From: Toomas Soome <tsoome@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359147 - head/stand/common Message-ID: <202003191727.02JHR8gd048985@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tsoome Date: Thu Mar 19 17:27:08 2020 New Revision: 359147 URL: https://svnweb.freebsd.org/changeset/base/359147 Log: loader: misaligned access of dos_partition structure armv7 crash due to misligned access of dos_partition dp_start field. Allocate and make copy of dos_partition array to make sure the data is aligned. Reported by: marklmi at yahoo.com Modified: head/stand/common/part.c Modified: head/stand/common/part.c ============================================================================== --- head/stand/common/part.c Thu Mar 19 17:20:50 2020 (r359146) +++ head/stand/common/part.c Thu Mar 19 17:27:08 2020 (r359147) @@ -654,6 +654,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect int has_ext; #endif table = NULL; + dp = NULL; buf = malloc(sectorsize); if (buf == NULL) return (NULL); @@ -708,7 +709,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect goto out; } /* Check that we have PMBR. Also do some validation. */ - dp = (struct dos_partition *)(buf + DOSPARTOFF); + dp = malloc(NDOSPART * sizeof(struct dos_partition)); + if (dp == NULL) + goto out; + bcopy(buf + DOSPARTOFF, dp, NDOSPART * sizeof(struct dos_partition)); + /* * In mac we can have PMBR partition in hybrid MBR; * that is, MBR partition which has DOSPTYP_PMBR entry defined as @@ -770,6 +775,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect #endif /* LOADER_MBR_SUPPORT */ #endif /* LOADER_MBR_SUPPORT || LOADER_GPT_SUPPORT */ out: + free(dp); free(buf); return (table); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003191727.02JHR8gd048985>