diff options
author | Brian Behlendorf <[email protected]> | 2014-01-07 23:24:37 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2014-01-09 15:50:15 -0800 |
commit | aa0218d6a12814fac50b287214f9f3b0b99e11b1 (patch) | |
tree | 697351bc65aca001f831b181d7b718b6ddeb05ea /module/nvpair | |
parent | 7f89ae6ba0f4e3c1b3e62272bbaa8228afdb020d (diff) |
Fix nvlist 'Bus Error' for Sparc
The mis-aligned memory accesses in nvpair_native_embedded() and
nvpair_native_embedded_array() will cause a 'Bus Error' for
architectures such as Sparc which not fully byte addressible.
To avoid this issue care is taken to avoid dereferencing the
potentially mis-aligned packed nvlist_t.
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ned Bass <[email protected]>
Signed-off-by: marku89 <[email protected]>
Issue #1700
Diffstat (limited to 'module/nvpair')
-rw-r--r-- | module/nvpair/nvpair.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 550356c58..f5c31663a 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -2580,7 +2580,8 @@ nvpair_native_embedded(nvstream_t *nvs, nvpair_t *nvp) * structure. The address may not be aligned, so we have * to use bzero. */ - bzero(&packed->nvl_priv, sizeof (packed->nvl_priv)); + bzero((char *)packed + offsetof(nvlist_t, nvl_priv), + sizeof (uint64_t)); } return (nvs_embedded(nvs, EMBEDDED_NVL(nvp))); @@ -2608,7 +2609,8 @@ nvpair_native_embedded_array(nvstream_t *nvs, nvpair_t *nvp) * packed structure. The address may not be aligned, * so we have to use bzero. */ - bzero(&packed->nvl_priv, sizeof (packed->nvl_priv)); + bzero((char *)packed + offsetof(nvlist_t, nvl_priv), + sizeof (uint64_t)); } return (nvs_embedded_nvl_array(nvs, nvp, NULL)); |