svn commit: r308137 - in head: sbin/geom/class/eli sys/geom/eli sys/modules/geom
Ruslan Bukin
br at FreeBSD.org
Mon Oct 31 16:55:15 UTC 2016
Author: br
Date: Mon Oct 31 16:55:14 2016
New Revision: 308137
URL: https://svnweb.freebsd.org/changeset/base/308137
Log:
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
Modified:
head/sbin/geom/class/eli/geom_eli.c
head/sys/geom/eli/g_eli.h
head/sys/geom/eli/g_eli_integrity.c
head/sys/modules/geom/Makefile
Modified: head/sbin/geom/class/eli/geom_eli.c
==============================================================================
--- head/sbin/geom/class/eli/geom_eli.c Mon Oct 31 16:48:16 2016 (r308136)
+++ head/sbin/geom/class/eli/geom_eli.c Mon Oct 31 16:55:14 2016 (r308137)
@@ -666,7 +666,7 @@ static void
eli_init(struct gctl_req *req)
{
struct g_eli_metadata md;
- unsigned char sector[sizeof(struct g_eli_metadata)];
+ unsigned char sector[sizeof(struct g_eli_metadata)] __aligned(4);
unsigned char key[G_ELI_USERKEYLEN];
char backfile[MAXPATHLEN];
const char *str, *prov;
Modified: head/sys/geom/eli/g_eli.h
==============================================================================
--- head/sys/geom/eli/g_eli.h Mon Oct 31 16:48:16 2016 (r308136)
+++ head/sys/geom/eli/g_eli.h Mon Oct 31 16:55:14 2016 (r308137)
@@ -289,6 +289,7 @@ eli_metadata_encode_v1v2v3v4v5v6v7(struc
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_metadat
}
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 *dat
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 *dat
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
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);
Modified: head/sys/geom/eli/g_eli_integrity.c
==============================================================================
--- head/sys/geom/eli/g_eli_integrity.c Mon Oct 31 16:48:16 2016 (r308136)
+++ head/sys/geom/eli/g_eli_integrity.c Mon Oct 31 16:55:14 2016 (r308137)
@@ -444,6 +444,7 @@ g_eli_auth_run(struct g_eli_worker *wr,
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,
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);
Modified: head/sys/modules/geom/Makefile
==============================================================================
--- head/sys/modules/geom/Makefile Mon Oct 31 16:48:16 2016 (r308136)
+++ head/sys/modules/geom/Makefile Mon Oct 31 16:55:14 2016 (r308137)
@@ -6,6 +6,7 @@ SYSDIR?=${.CURDIR}/../..
SUBDIR= geom_bde \
geom_cache \
geom_concat \
+ geom_eli \
geom_gate \
geom_journal \
geom_label \
@@ -29,9 +30,4 @@ SUBDIR= geom_bde \
SUBDIR+= geom_ccd
.endif
-# Alignment issues in g_eli_auth_run() on MIPS64 causes kernel panic
-.if ${MACHINE_ARCH} != "mips64" && ${MACHINE_ARCH} != "mips64el"
-SUBDIR+= geom_eli
-.endif
-
.include <bsd.subdir.mk>
More information about the svn-src-head
mailing list