Module Name: src
Committed By: maxv
Date: Sat May 30 08:41:23 UTC 2020
Modified Files:
src/sys/arch/amd64/include: ptrace.h
src/sys/arch/i386/include: ptrace.h
src/sys/kern: sys_ptrace_common.c
Log Message:
Introduce PTRACE_REGS_ALIGN, and on x86, enforce a 16-byte alignment, due
to fpregs having fxsave which requires 16-byte alignment.
Reported-by: [email protected]
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/include/ptrace.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/include/ptrace.h
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/sys_ptrace_common.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/include/ptrace.h
diff -u src/sys/arch/amd64/include/ptrace.h:1.21 src/sys/arch/amd64/include/ptrace.h:1.22
--- src/sys/arch/amd64/include/ptrace.h:1.21 Wed Jan 8 17:21:38 2020
+++ src/sys/arch/amd64/include/ptrace.h Sat May 30 08:41:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.21 2020/01/08 17:21:38 mgorny Exp $ */
+/* $NetBSD: ptrace.h,v 1.22 2020/05/30 08:41:22 maxv Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
@@ -101,6 +101,12 @@
int process_machdep_doxstate(struct lwp *, struct lwp *, struct uio *);
int process_machdep_validfpu(struct proc *);
+/*
+ * The fpregs structure contains an fxsave area, which must have 16-byte
+ * alignment.
+ */
+#define PTRACE_REGS_ALIGN __aligned(16)
+
#include <sys/module_hook.h>
MODULE_HOOK(netbsd32_process_doxmmregs_hook, int,
(struct lwp *, struct lwp *, void *, bool));
Index: src/sys/arch/i386/include/ptrace.h
diff -u src/sys/arch/i386/include/ptrace.h:1.25 src/sys/arch/i386/include/ptrace.h:1.26
--- src/sys/arch/i386/include/ptrace.h:1.25 Thu Jan 9 10:46:31 2020
+++ src/sys/arch/i386/include/ptrace.h Sat May 30 08:41:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.25 2020/01/09 10:46:31 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.26 2020/05/30 08:41:23 maxv Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -187,6 +187,12 @@ int procfs_machdep_doxmmregs(struct lwp
struct pfsnode *, struct uio *);
int procfs_machdep_validxmmregs(struct lwp *, struct mount *);
+/*
+ * The fpregs structure contains an fxsave area, which must have 16-byte
+ * alignment.
+ */
+#define PTRACE_REGS_ALIGN __aligned(16)
+
#endif /* _KERNEL */
#endif /* _I386_PTRACE_H_ */
Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.82 src/sys/kern/sys_ptrace_common.c:1.83
--- src/sys/kern/sys_ptrace_common.c:1.82 Tue May 26 23:08:56 2020
+++ src/sys/kern/sys_ptrace_common.c Sat May 30 08:41:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.82 2020/05/26 23:08:56 kamil Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.83 2020/05/30 08:41:22 maxv Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.82 2020/05/26 23:08:56 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.83 2020/05/30 08:41:22 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -214,6 +214,10 @@ static kcondvar_t ptrace_cv;
# define PT_REGISTERS
#endif
+#ifndef PTRACE_REGS_ALIGN
+#define PTRACE_REGS_ALIGN /* nothing */
+#endif
+
static int
ptrace_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
void *arg0, void *arg1, void *arg2, void *arg3)
@@ -1591,7 +1595,7 @@ static int
proc_regio(struct lwp *l, struct uio *uio, size_t ks, regrfunc_t r,
regwfunc_t w)
{
- char buf[1024];
+ char buf[1024] PTRACE_REGS_ALIGN;
int error;
char *kv;
size_t kl;