Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64/amd64 Replace misaligned operations with memc...
details: https://anonhg.NetBSD.org/src/rev/730e9b5f11c6
branches: trunk
changeset: 999294:730e9b5f11c6
user: kamil <kamil%NetBSD.org@localhost>
date: Tue May 28 03:52:08 2019 +0000
description:
Replace misaligned operations with memcpy() calls in kobj_machdep.c
Detected with kUBSan.
diffstat:
sys/arch/amd64/amd64/kobj_machdep.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diffs (61 lines):
diff -r 30bb6e4c3573 -r 730e9b5f11c6 sys/arch/amd64/amd64/kobj_machdep.c
--- a/sys/arch/amd64/amd64/kobj_machdep.c Tue May 28 01:20:02 2019 +0000
+++ b/sys/arch/amd64/amd64/kobj_machdep.c Tue May 28 03:52:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kobj_machdep.c,v 1.7 2018/12/24 21:48:52 christos Exp $ */
+/* $NetBSD: kobj_machdep.c,v 1.8 2019/05/28 03:52:08 kamil Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.7 2018/12/24 21:48:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.8 2019/05/28 03:52:08 kamil Exp $");
#define ELFSIZE ARCH_ELFSIZE
@@ -115,7 +115,7 @@
if (error)
return -1;
val = addr + addend;
- *where = val;
+ memcpy(where, &val, sizeof(val));
break;
case R_X86_64_PC32: /* S + A - P */
@@ -125,7 +125,7 @@
return -1;
where32 = (Elf32_Addr *)where;
val32 = (Elf32_Addr)(addr + addend - (Elf64_Addr)where);
- *where32 = val32;
+ memcpy(where32, &val32, sizeof(val32));
break;
case R_X86_64_32: /* S + A */
@@ -135,7 +135,7 @@
return -1;
val32 = (Elf32_Addr)(addr + addend);
where32 = (Elf32_Addr *)where;
- *where32 = val32;
+ memcpy(where32, &val32, sizeof(val32));
break;
case R_X86_64_GLOB_DAT: /* S */
@@ -143,13 +143,13 @@
error = kobj_sym_lookup(ko, symidx, &addr);
if (error)
return -1;
- *where = addr;
+ memcpy(where, &addr, sizeof(addr));
break;
case R_X86_64_RELATIVE: /* B + A */
addr = relocbase + addend;
val = addr;
- *where = val;
+ memcpy(where, &val, sizeof(val));
break;
default:
Home |
Main Index |
Thread Index |
Old Index