Date: Sun, 21 Apr 2019 04:15:57 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346480 - in stable/11/stand: common efi/libefi efi/loader fdt i386/pxeldr Message-ID: <201904210415.x3L4Fvse041679@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Sun Apr 21 04:15:57 2019 New Revision: 346480 URL: https://svnweb.freebsd.org/changeset/base/346480 Log: MFC r338262, r339334, r339796, r340240, r340857, r340917, r341007 r338262: stand: fdt: Drop some write-only assignments/variables and leaked bits Generally straightforward enough; a copy of argv[1] was being made in command_fdt_internal, solely used for a comparison within the handler-search, then promptly leaked. r339334: loader.efi: add poweroff command Add poweroff command to make life a bit easier. r339796: Simplify the EFI delay() function by calling BS->Stall() r340240: loader: ptable_open() check for ptable_cd9660read result is wrong The ptable_*read() functions return NULL on read errors (and partition table closed as an side effect). The ptable_open must check the return value and act properly. r340857: Nuke out buffer overflow safety marker code, it duplicates similar code in the malloc()/free() as well as having potential of softening the handling in case error is detected down to a mere warning as compared to hard panic in free(). r340917: Update pxeboot(8) manual page to reflect the next-server change in the ISC DHCP v3 server. r341007: Bump the date of pxeboot(8) manual page for r340917. PR: 123484, 232483 Modified: stable/11/stand/common/bcache.c stable/11/stand/common/part.c stable/11/stand/efi/libefi/delay.c stable/11/stand/efi/loader/main.c stable/11/stand/fdt/fdt_loader_cmd.c stable/11/stand/i386/pxeldr/pxeboot.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/common/bcache.c ============================================================================== --- stable/11/stand/common/bcache.c Sun Apr 21 04:00:19 2019 (r346479) +++ stable/11/stand/common/bcache.c Sun Apr 21 04:15:57 2019 (r346480) @@ -86,7 +86,6 @@ static u_int bcache_rablks; ((bc)->bcache_ctl[BHASH((bc), (blkno))].bc_blkno != (blkno)) #define BCACHE_READAHEAD 256 #define BCACHE_MINREADAHEAD 32 -#define BCACHE_MARKER 0xdeadbeef static void bcache_invalidate(struct bcache *bc, daddr_t blkno); static void bcache_insert(struct bcache *bc, daddr_t blkno); @@ -123,7 +122,6 @@ bcache_allocate(void) u_int i; struct bcache *bc = malloc(sizeof (struct bcache)); int disks = bcache_numdev; - uint32_t *marker; if (disks == 0) disks = 1; /* safe guard */ @@ -142,8 +140,7 @@ bcache_allocate(void) bc->bcache_nblks = bcache_total_nblks >> i; bcache_unit_nblks = bc->bcache_nblks; - bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize + - sizeof(uint32_t)); + bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize); if (bc->bcache_data == NULL) { /* dont error out yet. fall back to 32 blocks and try again */ bc->bcache_nblks = 32; @@ -158,9 +155,6 @@ bcache_allocate(void) errno = ENOMEM; return (NULL); } - /* Insert cache end marker. */ - marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); - *marker = BCACHE_MARKER; /* Flush the cache */ for (i = 0; i < bc->bcache_nblks; i++) { @@ -222,15 +216,12 @@ read_strategy(void *devdata, int rw, daddr_t blk, size int result; daddr_t p_blk; caddr_t p_buf; - uint32_t *marker; if (bc == NULL) { errno = ENODEV; return (-1); } - marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); - if (rsize != NULL) *rsize = 0; @@ -348,12 +339,6 @@ read_strategy(void *devdata, int rw, daddr_t blk, size if (size != 0) { bcopy(bc->bcache_data + (bcache_blksize * BHASH(bc, blk)), buf, size); result = 0; - } - - if (*marker != BCACHE_MARKER) { - printf("BUG: bcache corruption detected: nblks: %zu p_blk: %lu, " - "p_size: %zu, ra: %zu\n", bc->bcache_nblks, - (long unsigned)BHASH(bc, p_blk), p_size, ra); } done: Modified: stable/11/stand/common/part.c ============================================================================== --- stable/11/stand/common/part.c Sun Apr 21 04:00:19 2019 (r346479) +++ stable/11/stand/common/part.c Sun Apr 21 04:15:57 2019 (r346480) @@ -675,10 +675,12 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect table->type = PTABLE_NONE; STAILQ_INIT(&table->entries); - if (ptable_iso9660read(table, dev, dread) != NULL) { - if (table->type == PTABLE_ISO9660) - goto out; - } + if (ptable_iso9660read(table, dev, dread) == NULL) { + /* Read error. */ + table = NULL; + goto out; + } else if (table->type == PTABLE_ISO9660) + goto out; #ifdef LOADER_VTOC8_SUPPORT if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { Modified: stable/11/stand/efi/libefi/delay.c ============================================================================== --- stable/11/stand/efi/libefi/delay.c Sun Apr 21 04:00:19 2019 (r346479) +++ stable/11/stand/efi/libefi/delay.c Sun Apr 21 04:15:57 2019 (r346480) @@ -33,15 +33,5 @@ __FBSDID("$FreeBSD$"); void delay(int usecs) { - static EFI_EVENT ev = 0; - UINTN junk; - - if (!ev) { - if (BS->CreateEvent(EVT_TIMER, TPL_APPLICATION, 0, 0, &ev) - != EFI_SUCCESS) - return; - } - - BS->SetTimer(ev, TimerRelative, usecs * 10); - BS->WaitForEvent(1, &ev, &junk); + BS->Stall(usecs); } Modified: stable/11/stand/efi/loader/main.c ============================================================================== --- stable/11/stand/efi/loader/main.c Sun Apr 21 04:00:19 2019 (r346479) +++ stable/11/stand/efi/loader/main.c Sun Apr 21 04:15:57 2019 (r346480) @@ -746,6 +746,23 @@ main(int argc, CHAR16 *argv[]) return (EFI_SUCCESS); /* keep compiler happy */ } +COMMAND_SET(poweroff, "poweroff", "power off the system", command_poweroff); + +static int +command_poweroff(int argc __unused, char *argv[] __unused) +{ + int i; + + for (i = 0; devsw[i] != NULL; ++i) + if (devsw[i]->dv_cleanup != NULL) + (devsw[i]->dv_cleanup)(); + + RS->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL); + + /* NOTREACHED */ + return (CMD_ERROR); +} + COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); static int Modified: stable/11/stand/fdt/fdt_loader_cmd.c ============================================================================== --- stable/11/stand/fdt/fdt_loader_cmd.c Sun Apr 21 04:00:19 2019 (r346479) +++ stable/11/stand/fdt/fdt_loader_cmd.c Sun Apr 21 04:15:57 2019 (r346480) @@ -848,7 +848,6 @@ void fdt_fixup_stdout(const char *str) { char *ptr; - int serialno; int len, no, sero; const struct fdt_property *prop; char *tmp[10]; @@ -860,7 +859,6 @@ fdt_fixup_stdout(const char *str) if (ptr == str) return; - serialno = (int)strtol(ptr, NULL, 0); no = fdt_path_offset(fdtp, "/chosen"); if (no < 0) return; @@ -917,10 +915,8 @@ fdt_load_dtb_overlays(const char *extras) static int fdt_fixup(void) { - int chosen, len; + int chosen; - len = 0; - debugf("fdt_fixup()\n"); if (fdtp == NULL && fdt_setup_fdtp() != 0) @@ -977,7 +973,6 @@ command_fdt_internal(int argc, char *argv[]) { cmdf_t *cmdh; int flags; - char *cmd; int i, err; if (argc < 2) { @@ -988,11 +983,10 @@ command_fdt_internal(int argc, char *argv[]) /* * Validate fdt <command>. */ - cmd = strdup(argv[1]); i = 0; cmdh = NULL; while (!(commands[i].name == NULL)) { - if (strcmp(cmd, commands[i].name) == 0) { + if (strcmp(argv[1], commands[i].name) == 0) { /* found it */ cmdh = commands[i].handler; flags = commands[i].flags; @@ -1516,7 +1510,6 @@ fdt_modprop(int nodeoff, char *propname, void *value, sprintf(command_errbuf, "property does not exist!"); return (CMD_ERROR); } - len = strlen(value); rv = 0; buf = value; Modified: stable/11/stand/i386/pxeldr/pxeboot.8 ============================================================================== --- stable/11/stand/i386/pxeldr/pxeboot.8 Sun Apr 21 04:00:19 2019 (r346479) +++ stable/11/stand/i386/pxeldr/pxeboot.8 Sun Apr 21 04:15:57 2019 (r346480) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 27, 2017 +.Dd November 25, 2018 .Dt PXEBOOT 8 .Os .Sh NAME @@ -58,7 +58,7 @@ The .Nm binary is loaded just like any other boot file, by specifying it in the DHCP server's configuration file. -Below is a sample configuration for the ISC DHCP v2 server: +Below is a sample configuration for the ISC DHCP v3 server: .Bd -literal -offset indent option domain-name "example.com"; option routers 10.0.0.1; @@ -67,6 +67,7 @@ option broadcast-address 10.0.0.255; option domain-name-servers 10.0.0.1; server-name "DHCPserver"; server-identifier 10.0.0.1; +next-server 10.0.0.1; default-lease-time 120; max-lease-time 120; @@ -80,10 +81,11 @@ subnet 10.0.0.0 netmask 255.255.255.0 { } .Ed +.Va next-server +is the IP address of the next server in the bootstrap process, i.e. +your TFTP server or NFS server. .Nm recognizes -.Va next-server -and .Va option root-path directives as the server and path to NFS mount for file requests, respectively, or the server to make TFTP requests to.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904210415.x3L4Fvse041679>