From 1227a4f4ea7e170248f5136529463e2bea5bda18 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 2 Dec 2017 00:07:37 +0000 Subject: [PATCH] Fix all warnings related to geli and ZFS support on x86. Default WARNS to 0 still, since there's still some warnings on other architectures. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D13301 --- stand/defs.mk | 2 ++ stand/geli/Makefile | 2 -- stand/geli/geliboot.c | 6 +++--- stand/i386/gptboot/gptboot.c | 8 +++++++- stand/i386/libi386/biosdisk.c | 12 ++++++------ stand/i386/zfsboot/zfsboot.c | 32 +++++++++++++++++++++----------- stand/libsa/Makefile | 1 - stand/zfs/zfsimpl.c | 3 ++- sys/cddl/boot/zfs/zfssubr.c | 2 +- 9 files changed, 42 insertions(+), 26 deletions(-) diff --git a/stand/defs.mk b/stand/defs.mk index 2babe26ef95a..3b52b4eb4e6b 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -2,6 +2,8 @@ .include +WARNS?=0 + .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} diff --git a/stand/geli/Makefile b/stand/geli/Makefile index 19e246fa9be6..ce54f82a0a2e 100644 --- a/stand/geli/Makefile +++ b/stand/geli/Makefile @@ -12,8 +12,6 @@ INTERNALLIB= MK_PROFILE= no NO_PIC= -WARNS?= 0 - # Our password input method SRCS+= pwgets.c diff --git a/stand/geli/geliboot.c b/stand/geli/geliboot.c index 2fca7ba513db..f475f4178cf7 100644 --- a/stand/geli/geliboot.c +++ b/stand/geli/geliboot.c @@ -222,7 +222,7 @@ geli_taste(int read_func(void *vdev, void *priv, off_t off, void *buf, */ static int geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase, - const u_char *mkeyp) + u_char *mkeyp) { u_char key[G_ELI_USERKEYLEN], mkey[G_ELI_DATAIVKEYLEN], *mkp; u_int keynum; @@ -248,7 +248,7 @@ geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase, } else if (geli_e->md.md_iterations == 0) { g_eli_crypto_hmac_update(&ctx, geli_e->md.md_salt, sizeof(geli_e->md.md_salt)); - g_eli_crypto_hmac_update(&ctx, passphrase, + g_eli_crypto_hmac_update(&ctx, (const uint8_t *)passphrase, strlen(passphrase)); } else if (geli_e->md.md_iterations > 0) { printf("Calculating GELI Decryption Key disk%dp%d @ %d" @@ -294,7 +294,7 @@ geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase, /* * The encryption key is: ekey = HMAC_SHA512(Data-Key, 0x10) */ - g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, "\x10", 1, + g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, (const uint8_t *)"\x10", 1, geli_e->sc.sc_ekey, 0); } explicit_bzero(mkey, sizeof(mkey)); diff --git a/stand/i386/gptboot/gptboot.c b/stand/i386/gptboot/gptboot.c index dd06f0c59391..80e02ec865ad 100644 --- a/stand/i386/gptboot/gptboot.c +++ b/stand/i386/gptboot/gptboot.c @@ -32,6 +32,10 @@ __FBSDID("$FreeBSD$"); #include +/* Forward declared to avoid warnings -- these shouldn't be needed */ +int strcasecmp(const char *s1, const char *s2); +void explicit_bzero(void *b, size_t len); + #include "bootargs.h" #include "lib.h" #include "rbx.h" @@ -254,7 +258,7 @@ gptinit(void) #ifdef LOADER_GELI_SUPPORT if (geli_taste(vdev_read, &dsk, (gpttable[curent].ent_lba_end - gpttable[curent].ent_lba_start)) == 0) { - if (geli_havekey(&dsk) != 0 && geli_passphrase(&gelipw, + if (geli_havekey(&dsk) != 0 && geli_passphrase(gelipw, dsk.unit, 'p', curent + 1, &dsk) != 0) { printf("%s: unable to decrypt GELI key\n", BOOTPROG); return (-1); @@ -266,6 +270,8 @@ gptinit(void) return (0); } +int main(void); + int main(void) { diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c index a2147e2294f5..264451484b06 100644 --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -146,8 +146,7 @@ enum isgeli { }; static enum isgeli geli_status[MAXBDDEV][MAXTBLENTS]; -int bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, - size_t bytes); +int bios_read(void *, void *, off_t off, void *buf, size_t bytes); #endif /* LOADER_GELI_SUPPORT */ struct devsw biosdisk = { @@ -482,10 +481,10 @@ bd_open(struct open_file *f, ...) /* Use the cached passphrase */ bcopy(passphrase, &gelipw, GELI_PW_MAXLEN); } - if (geli_passphrase(&gelipw, dskp.unit, 'p', + if (geli_passphrase(gelipw, dskp.unit, 'p', (dskp.slice > 0 ? dskp.slice : dskp.part), &dskp) == 0) { - setenv("kern.geom.eli.passphrase", &gelipw, 1); + setenv("kern.geom.eli.passphrase", gelipw, 1); bzero(gelipw, sizeof(gelipw)); geli_status[dev->d_unit][dskp.slice] = ISGELI_YES; geli_part++; @@ -882,7 +881,7 @@ bd_read(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest) /* GELI needs the offset relative to the partition start */ p_off = alignlba - dskp.start; - err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, tmpbuf, + err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, (u_char *)tmpbuf, alignblks * BD(dev).bd_sectorsize); if (err) return (err); @@ -992,9 +991,10 @@ bd_getdev(struct i386_devdesc *d) #ifdef LOADER_GELI_SUPPORT int -bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, size_t bytes) +bios_read(void *vdev __unused, void *xpriv, off_t off, void *buf, size_t bytes) { struct disk_devdesc dev; + struct dsk *priv = xpriv; dev.d_dev = &biosdisk; dev.d_type = priv->type; diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index 88b5231efe45..a568f6886b78 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -36,6 +36,10 @@ __FBSDID("$FreeBSD$"); #include +/* Forward declared to avoid warnings -- these shouldn't be needed */ +int strcasecmp(const char *s1, const char *s2); +void explicit_bzero(void *b, size_t len); + #include "lib.h" #include "rbx.h" #include "drv.h" @@ -96,7 +100,6 @@ static int comspeed = SIOSPD; static struct bootinfo bootinfo; static uint32_t bootdev; static struct zfs_boot_args zfsargs; -static struct zfsmount zfsmount; vm_offset_t high_heap_base; uint32_t bios_basemem, bios_extmem, high_heap_size; @@ -200,7 +203,7 @@ static vdev_t *primary_vdev; * buffer pointer crosses a 64k boundary. */ static int -vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +vdev_read(void *xvdev, void *priv, off_t off, void *buf, size_t bytes) { char *p; daddr_t lba, alignlba; @@ -262,6 +265,13 @@ vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) return 0; } +/* Match the signature exactly due to signature madness */ +static int +vdev_read2(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +{ + return vdev_read(vdev, priv, off, buf, bytes); +} + static int vdev_write(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) @@ -557,7 +567,7 @@ probe_drive(struct dsk *dsk) /* * If we find a vdev on the whole disk, stop here. */ - if (vdev_probe(vdev_read, dsk, NULL) == 0) + if (vdev_probe(vdev_read2, dsk, NULL) == 0) return; #ifdef LOADER_GELI_SUPPORT @@ -572,9 +582,9 @@ probe_drive(struct dsk *dsk) elba--; } if (geli_taste(vdev_read, dsk, elba) == 0) { - if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit, + if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit, ':', 0, dsk) == 0) { - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { return; } } @@ -621,7 +631,7 @@ probe_drive(struct dsk *dsk) dsk->size = ent->ent_lba_end - ent->ent_lba_start + 1; dsk->slice = part + 1; dsk->part = 255; - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. @@ -631,12 +641,12 @@ probe_drive(struct dsk *dsk) #ifdef LOADER_GELI_SUPPORT else if (geli_taste(vdev_read, dsk, ent->ent_lba_end - ent->ent_lba_start) == 0) { - if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, + if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit, 'p', dsk->slice, dsk) == 0) { /* * This slice has GELI, check it for ZFS. */ - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. @@ -665,18 +675,18 @@ probe_drive(struct dsk *dsk) dsk->start = dp[i].dp_start; dsk->size = dp[i].dp_size; dsk->slice = i + 1; - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { dsk = copy_dsk(dsk); } #ifdef LOADER_GELI_SUPPORT else if (geli_taste(vdev_read, dsk, dp[i].dp_size - dp[i].dp_start) == 0) { - if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit, + if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit, 's', i, dsk) == 0) { /* * This slice has GELI, check it for ZFS. */ - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile index fc57e7eb6e20..5b57c56292bf 100644 --- a/stand/libsa/Makefile +++ b/stand/libsa/Makefile @@ -17,7 +17,6 @@ LIBC_SRC= ${SRCTOP}/lib/libc LIB?= sa NO_PIC= -WARNS?= 0 # standalone components and stuff we have modified locally SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \ diff --git a/stand/zfs/zfsimpl.c b/stand/zfs/zfsimpl.c index 6e0d9b6fe775..30849db56923 100644 --- a/stand/zfs/zfsimpl.c +++ b/stand/zfs/zfsimpl.c @@ -43,6 +43,7 @@ struct zfsmount { objset_phys_t objset; uint64_t rootobj; }; +static struct zfsmount zfsmount; /* * List of all vdevs, chained through v_alllink. @@ -913,7 +914,7 @@ spa_all_status(void) return (ret); } -uint64_t +static uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset) { uint64_t label_offset; diff --git a/sys/cddl/boot/zfs/zfssubr.c b/sys/cddl/boot/zfs/zfssubr.c index 805cb42d2efa..261aa3b872d7 100644 --- a/sys/cddl/boot/zfs/zfssubr.c +++ b/sys/cddl/boot/zfs/zfssubr.c @@ -250,7 +250,7 @@ zio_checksum_template_init(enum zio_checksum checksum, spa_t *spa) * all of the checksum context templates and deallocates any that were * initialized using the algorithm-specific template init function. */ -void +static void zio_checksum_templates_free(spa_t *spa) { for (enum zio_checksum checksum = 0;