Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Apr 2018 13:39:53 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r332069 - stable/10/sys/amd64/amd64
Message-ID:  <201804051339.w35DdrwI008285@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Apr  5 13:39:53 2018
New Revision: 332069
URL: https://svnweb.freebsd.org/changeset/base/332069

Log:
  MFC r331374:
  Fixes for ptrace(PT_GETXSTATE_INFO) related to the padding in struct
  ptrace_xstate_info).

Modified:
  stable/10/sys/amd64/amd64/ptrace_machdep.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/amd64/ptrace_machdep.c
==============================================================================
--- stable/10/sys/amd64/amd64/ptrace_machdep.c	Thu Apr  5 12:59:50 2018	(r332068)
+++ stable/10/sys/amd64/amd64/ptrace_machdep.c	Thu Apr  5 13:39:53 2018	(r332069)
@@ -43,10 +43,20 @@ __FBSDID("$FreeBSD$");
 #include <machine/frame.h>
 #include <machine/vmparam.h>
 
+#ifdef COMPAT_FREEBSD32
+struct ptrace_xstate_info32 {
+	uint32_t	xsave_mask1, xsave_mask2;
+	uint32_t	xsave_len;
+};
+#endif
+
 static int
 cpu_ptrace_xstate(struct thread *td, int req, void *addr, int data)
 {
 	struct ptrace_xstate_info info;
+#ifdef COMPAT_FREEBSD32
+	struct ptrace_xstate_info32 info32;
+#endif
 	char *savefpu;
 	int error;
 
@@ -76,13 +86,28 @@ cpu_ptrace_xstate(struct thread *td, int req, void *ad
 		break;
 
 	case PT_GETXSTATE_INFO:
-		if (data != sizeof(info)) {
-			error  = EINVAL;
-			break;
+#ifdef COMPAT_FREEBSD32
+		if (SV_CURPROC_FLAG(SV_ILP32)) {
+			if (data != sizeof(info32)) {
+				error = EINVAL;
+			} else {
+				info32.xsave_len = cpu_max_ext_state_size;
+				info32.xsave_mask1 = xsave_mask;
+				info32.xsave_mask2 = xsave_mask >> 32;
+				error = copyout(&info32, addr, data);
+			}
+		} else
+#endif
+		{
+			if (data != sizeof(info)) {
+				error  = EINVAL;
+			} else {
+				bzero(&info, sizeof(info));
+				info.xsave_len = cpu_max_ext_state_size;
+				info.xsave_mask = xsave_mask;
+				error = copyout(&info, addr, data);
+			}
 		}
-		info.xsave_len = cpu_max_ext_state_size;
-		info.xsave_mask = xsave_mask;
-		error = copyout(&info, addr, data);
 		break;
 
 	case PT_GETXSTATE:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804051339.w35DdrwI008285>