git: 51ddd2851e4a - stable/12 - loader: misaligned access of dos_partition structure
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Oct 2021 01:16:38 UTC
The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=51ddd2851e4a36e28cf78dfe06125723f7d2b113 commit 51ddd2851e4a36e28cf78dfe06125723f7d2b113 Author: Toomas Soome <tsoome@FreeBSD.org> AuthorDate: 2020-03-19 17:27:08 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2021-10-08 01:15:59 +0000 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. (cherry picked from commit 87d8d5ea3dd0a8ad2c0468660805017d6d45d937) --- stand/common/part.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stand/common/part.c b/stand/common/part.c index b84678efd3cc..69df57abb175 100644 --- a/stand/common/part.c +++ b/stand/common/part.c @@ -662,6 +662,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, int has_ext; #endif table = NULL; + dp = NULL; buf = malloc(sectorsize); if (buf == NULL) return (NULL); @@ -716,7 +717,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, 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 @@ -778,6 +783,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, #endif /* LOADER_MBR_SUPPORT */ #endif /* LOADER_MBR_SUPPORT || LOADER_GPT_SUPPORT */ out: + free(dp); free(buf); return (table); }