aboutsummaryrefslogtreecommitdiff
path: root/sys/geom
diff options
context:
space:
mode:
authorRuslan Bukin <br@FreeBSD.org>2016-10-31 16:55:14 +0000
committerRuslan Bukin <br@FreeBSD.org>2016-10-31 16:55:14 +0000
commitae8b1f90fecd606bbf17c74500fec4f91a3c8c04 (patch)
treed11d775b4f89ea0864ff1587895af7ad6f3a44da /sys/geom
parent2668ec0761a2d536161c5c6cef99159c8c09c212 (diff)
downloadsrc-ae8b1f90fecd606bbf17c74500fec4f91a3c8c04.tar.gz
src-ae8b1f90fecd606bbf17c74500fec4f91a3c8c04.zip
Fix alignment issues on MIPS: align the pointers properly.
All the 5520 GEOM_ELI tests passed successfully on MIPS64EB. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D7905
Notes
Notes: svn path=/head/; revision=308137
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/eli/g_eli.h12
-rw-r--r--sys/geom/eli/g_eli_integrity.c5
2 files changed, 14 insertions, 3 deletions
diff --git a/sys/geom/eli/g_eli.h b/sys/geom/eli/g_eli.h
index 13e780762549..b6a28d05a9a6 100644
--- a/sys/geom/eli/g_eli.h
+++ b/sys/geom/eli/g_eli.h
@@ -289,6 +289,7 @@ eli_metadata_encode_v1v2v3v4v5v6v7(struct g_eli_metadata *md, u_char **datap)
static __inline void
eli_metadata_encode(struct g_eli_metadata *md, u_char *data)
{
+ uint32_t hash[4];
MD5_CTX ctx;
u_char *p;
@@ -320,12 +321,14 @@ eli_metadata_encode(struct g_eli_metadata *md, u_char *data)
}
MD5Init(&ctx);
MD5Update(&ctx, data, p - data);
- MD5Final(md->md_hash, &ctx);
+ MD5Final((void *)hash, &ctx);
+ bcopy(hash, md->md_hash, sizeof(md->md_hash));
bcopy(md->md_hash, p, sizeof(md->md_hash));
}
static __inline int
eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md)
{
+ uint32_t hash[4];
MD5_CTX ctx;
const u_char *p;
@@ -341,7 +344,8 @@ eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md)
bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys);
MD5Init(&ctx);
MD5Update(&ctx, data, p - data);
- MD5Final(md->md_hash, &ctx);
+ MD5Final((void *)hash, &ctx);
+ bcopy(hash, md->md_hash, sizeof(md->md_hash));
if (bcmp(md->md_hash, p, 16) != 0)
return (EINVAL);
return (0);
@@ -350,6 +354,7 @@ eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md)
static __inline int
eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata *md)
{
+ uint32_t hash[4];
MD5_CTX ctx;
const u_char *p;
@@ -366,7 +371,8 @@ eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata *md
bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys);
MD5Init(&ctx);
MD5Update(&ctx, data, p - data);
- MD5Final(md->md_hash, &ctx);
+ MD5Final((void *)hash, &ctx);
+ bcopy(hash, md->md_hash, sizeof(md->md_hash));
if (bcmp(md->md_hash, p, 16) != 0)
return (EINVAL);
return (0);
diff --git a/sys/geom/eli/g_eli_integrity.c b/sys/geom/eli/g_eli_integrity.c
index f68800197eda..6ff0d18566ee 100644
--- a/sys/geom/eli/g_eli_integrity.c
+++ b/sys/geom/eli/g_eli_integrity.c
@@ -444,6 +444,7 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp)
size += sizeof(*crde) * nsec;
size += sizeof(*crda) * nsec;
size += G_ELI_AUTH_SECKEYLEN * nsec;
+ size += sizeof(uintptr_t); /* Space for alignment. */
data = malloc(size, M_ELI, M_WAITOK);
bp->bio_driver2 = data;
p = data + encr_secsize * nsec;
@@ -451,6 +452,10 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp)
bp->bio_inbed = 0;
bp->bio_children = nsec;
+#if defined(__mips_n64) || defined(__mips_o64)
+ p = (char *)roundup((uintptr_t)p, sizeof(uintptr_t));
+#endif
+
for (i = 1; i <= nsec; i++, dstoff += encr_secsize) {
crp = (struct cryptop *)p; p += sizeof(*crp);
crde = (struct cryptodesc *)p; p += sizeof(*crde);