From ee059e63696db138feef3a38e2dde12a8c5a028d Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 29 Jun 2017 04:33:55 +0000 Subject: [PATCH] loader: chain load relocate data declaration is bad The implementation is using fixed size array allocated in asm module, need to use proper array declaration for C source. CID: 1376405 Reported by: Coverity, cem Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D11321 --- sys/boot/i386/libi386/libi386.h | 5 ++++- sys/boot/i386/loader/chain.c | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h index 8cc7452270a..e65a060acb7 100644 --- a/sys/boot/i386/libi386/libi386.h +++ b/sys/boot/i386/libi386/libi386.h @@ -71,7 +71,10 @@ struct relocate_data { extern void relocater(void); -extern uint32_t relocater_data; +/* + * The relocater_data[] is fixed size array allocated in relocater_tramp.S + */ +extern struct relocate_data relocater_data[]; extern uint32_t relocater_size; extern uint16_t relocator_ip; diff --git a/sys/boot/i386/loader/chain.c b/sys/boot/i386/loader/chain.c index f8c83d82e9a..d6810ef67fc 100644 --- a/sys/boot/i386/loader/chain.c +++ b/sys/boot/i386/loader/chain.c @@ -58,7 +58,6 @@ command_chain(int argc, char *argv[]) int fd, len, size = SECTOR_SIZE; struct stat st; vm_offset_t mem = 0x100000; - uint32_t *uintptr = &relocater_data; struct i386_devdesc *rootdev; if (argc == 1) { @@ -108,9 +107,9 @@ command_chain(int argc, char *argv[]) return (CMD_ERROR); } - uintptr[0] = mem; - uintptr[1] = 0x7C00; - uintptr[2] = SECTOR_SIZE; + relocater_data[0].src = mem; + relocater_data[0].dest = 0x7C00; + relocater_data[0].size = SECTOR_SIZE; relocator_edx = bd_unit2bios(rootdev->d_unit); relocator_esi = relocater_size;