From owner-svn-src-stable@freebsd.org Thu Mar 29 15:08:41 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15A50F52870; Thu, 29 Mar 2018 15:08:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BBF0C72CA6; Thu, 29 Mar 2018 15:08:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6A951B78E; Thu, 29 Mar 2018 15:08:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2TF8evL045474; Thu, 29 Mar 2018 15:08:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2TF8ebP045473; Thu, 29 Mar 2018 15:08:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201803291508.w2TF8ebP045473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 29 Mar 2018 15:08:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331735 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 331735 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2018 15:08:41 -0000 Author: kib Date: Thu Mar 29 15:08:40 2018 New Revision: 331735 URL: https://svnweb.freebsd.org/changeset/base/331735 Log: MFC r331374: Fixes for ptrace(PT_GETXSTATE_INFO) related to the padding in struct ptrace_xstate_info). Modified: stable/11/sys/amd64/amd64/ptrace_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/ptrace_machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/ptrace_machdep.c Thu Mar 29 15:01:01 2018 (r331734) +++ stable/11/sys/amd64/amd64/ptrace_machdep.c Thu Mar 29 15:08:40 2018 (r331735) @@ -43,10 +43,20 @@ __FBSDID("$FreeBSD$"); #include #include +#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: