]> granicus.if.org Git - zfs/commitdiff
Fix nvlist 'Bus Error' for Sparc
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 7 Jan 2014 22:24:37 +0000 (23:24 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 9 Jan 2014 23:50:15 +0000 (15:50 -0800)
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 <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: marku89 <mar42@kola.li>
Issue #1700

module/nvpair/nvpair.c

index 550356c58d7205ddd66583e0f2b407b4dd229cf9..f5c31663a70ccfcfd31a5b6ba739ff7d4460ee49 100644 (file)
@@ -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));