From f32ec2346b9f276ddb40ce92f49174127c2b3e48 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 25 Jun 2010 14:13:37 -0700 Subject: [PATCH] Linux bcopy() requires word aligned memory, use memcpy() Much to my surprise bcopy() under Linux appears to copy the data in word sized chunks. It does the right thing but if you buffer is not a multiple of the word size you will be reading past the end of your buffer. Or at least that is what valgrind is reporting. We should be using mempcy() anyway on Linux so replace bcopy() with memcpy() to resolve the issue. ==305== Thread 211: ==305== Invalid read of size 8 ==305== at 0x3BCD28357D: _wordcopy_fwd_dest_aligned (in /lib64/libc-2.11.1.so) ==305== by 0x3BCD282B05: bcopy (in /lib64/libc-2.11.1.so) ==305== by 0x58D7FEF: dmu_write (dmu.c:730) ==305== by 0x591C942: spa_history_write (spa_history.c:165) ==305== by 0x591D255: spa_history_log_sync (spa_history.c:277) ==305== by 0x591D545: log_internal (spa_history.c:450) ==305== by 0x591D5EC: spa_history_log_internal (spa_history.c:475) ==305== by 0x5902319: dsl_prop_set_sync (dsl_prop.c:707) ==305== by 0x5906A7D: dsl_sync_task_group_sync (dsl_synctask.c:199) ==305== by 0x58FF4EC: dsl_pool_sync (dsl_pool.c:376) ==305== by 0x591744C: spa_sync (spa.c:5365) ==305== by 0x5922C85: txg_sync_thread (txg.c:414) --- module/zfs/dmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index dd09dda18e..53a1d3bc5b 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -727,7 +727,7 @@ dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, else dmu_buf_will_dirty(db, tx); - bcopy(buf, (char *)db->db_data + bufoff, tocpy); + (void) memcpy((char *)db->db_data + bufoff, buf, tocpy); if (tocpy == db->db_size) dmu_buf_fill_done(db, tx);