From owner-svn-src-stable@freebsd.org Tue Dec 4 19:06:14 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 0A96C1317F61; Tue, 4 Dec 2018 19:06:14 +0000 (UTC) (envelope-from markj@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 877D26D0F6; Tue, 4 Dec 2018 19:06:13 +0000 (UTC) (envelope-from markj@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 60C2B15DA; Tue, 4 Dec 2018 19:06:13 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB4J6Dld001125; Tue, 4 Dec 2018 19:06:13 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB4J6Br6001116; Tue, 4 Dec 2018 19:06:11 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201812041906.wB4J6Br6001116@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Dec 2018 19:06:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r341490 - in stable/12/sys: amd64/amd64 amd64/ia32 arm/arm fs/procfs i386/i386 kern sparc64/sparc64 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 amd64/ia32 arm/arm fs/procfs i386/i386 kern sparc64/sparc64 X-SVN-Commit-Revision: 341490 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 877D26D0F6 X-Spamd-Result: default: False [-0.39 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.48)[-0.475,0]; NEURAL_SPAM_SHORT(0.13)[0.133,0]; NEURAL_HAM_LONG(-0.05)[-0.046,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 04 Dec 2018 19:06:14 -0000 Author: markj Date: Tue Dec 4 19:06:11 2018 New Revision: 341490 URL: https://svnweb.freebsd.org/changeset/base/341490 Log: MFC r341442, r341443: Plug memory disclosures via ptrace(2). Modified: stable/12/sys/amd64/amd64/machdep.c stable/12/sys/amd64/ia32/ia32_reg.c stable/12/sys/arm/arm/machdep_kdb.c stable/12/sys/fs/procfs/procfs_dbregs.c stable/12/sys/fs/procfs/procfs_fpregs.c stable/12/sys/fs/procfs/procfs_regs.c stable/12/sys/i386/i386/machdep.c stable/12/sys/kern/sys_process.c stable/12/sys/sparc64/sparc64/machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/amd64/amd64/machdep.c Tue Dec 4 19:06:11 2018 (r341490) @@ -2046,6 +2046,7 @@ fill_regs(struct thread *td, struct reg *regs) int fill_frame_regs(struct trapframe *tp, struct reg *regs) { + regs->r_r15 = tp->tf_r15; regs->r_r14 = tp->tf_r14; regs->r_r13 = tp->tf_r13; @@ -2077,6 +2078,8 @@ fill_frame_regs(struct trapframe *tp, struct reg *regs regs->r_fs = 0; regs->r_gs = 0; } + regs->r_err = 0; + regs->r_trapno = 0; return (0); } Modified: stable/12/sys/amd64/ia32/ia32_reg.c ============================================================================== --- stable/12/sys/amd64/ia32/ia32_reg.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/amd64/ia32/ia32_reg.c Tue Dec 4 19:06:11 2018 (r341490) @@ -105,6 +105,8 @@ fill_regs32(struct thread *td, struct reg32 *regs) regs->r_eflags = tp->tf_rflags; regs->r_esp = tp->tf_rsp; regs->r_ss = tp->tf_ss; + regs->r_err = 0; + regs->r_trapno = 0; return (0); } Modified: stable/12/sys/arm/arm/machdep_kdb.c ============================================================================== --- stable/12/sys/arm/arm/machdep_kdb.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/arm/arm/machdep_kdb.c Tue Dec 4 19:06:11 2018 (r341490) @@ -104,6 +104,7 @@ fill_regs(struct thread *td, struct reg *regs) regs->r_cpsr = tf->tf_spsr; return (0); } + int fill_fpregs(struct thread *td, struct fpreg *regs) { @@ -134,8 +135,11 @@ set_fpregs(struct thread *td, struct fpreg *regs) int fill_dbregs(struct thread *td, struct dbreg *regs) { + + bzero(regs, sizeof(*regs)); return (0); } + int set_dbregs(struct thread *td, struct dbreg *regs) { Modified: stable/12/sys/fs/procfs/procfs_dbregs.c ============================================================================== --- stable/12/sys/fs/procfs/procfs_dbregs.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/fs/procfs/procfs_dbregs.c Tue Dec 4 19:06:11 2018 (r341490) @@ -112,8 +112,10 @@ procfs_doprocdbregs(PFS_FILL_ARGS) return (EINVAL); } wrap32 = 1; - } + memset(&r32, 0, sizeof(r32)); + } else #endif + memset(&r, 0, sizeof(r)); error = PROC(read, dbregs, td2, &r); if (error == 0) { PROC_UNLOCK(p); Modified: stable/12/sys/fs/procfs/procfs_fpregs.c ============================================================================== --- stable/12/sys/fs/procfs/procfs_fpregs.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/fs/procfs/procfs_fpregs.c Tue Dec 4 19:06:11 2018 (r341490) @@ -102,7 +102,6 @@ procfs_doprocfpregs(PFS_FILL_ARGS) return (EBUSY); } - /* XXXKSE: */ td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { @@ -111,8 +110,10 @@ procfs_doprocfpregs(PFS_FILL_ARGS) return (EINVAL); } wrap32 = 1; - } + memset(&r32, 0, sizeof(r32)); + } else #endif + memset(&r, 0, sizeof(r)); error = PROC(read, fpregs, td2, &r); if (error == 0) { PROC_UNLOCK(p); Modified: stable/12/sys/fs/procfs/procfs_regs.c ============================================================================== --- stable/12/sys/fs/procfs/procfs_regs.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/fs/procfs/procfs_regs.c Tue Dec 4 19:06:11 2018 (r341490) @@ -102,7 +102,6 @@ procfs_doprocregs(PFS_FILL_ARGS) return (EBUSY); } - /* XXXKSE: */ td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { @@ -111,8 +110,10 @@ procfs_doprocregs(PFS_FILL_ARGS) return (EINVAL); } wrap32 = 1; - } + memset(&r32, 0, sizeof(r32)); + } else #endif + memset(&r, 0, sizeof(r)); error = PROC(read, regs, td2, &r); if (error == 0) { PROC_UNLOCK(p); Modified: stable/12/sys/i386/i386/machdep.c ============================================================================== --- stable/12/sys/i386/i386/machdep.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/i386/i386/machdep.c Tue Dec 4 19:06:11 2018 (r341490) @@ -2817,6 +2817,7 @@ fill_regs(struct thread *td, struct reg *regs) int fill_frame_regs(struct trapframe *tp, struct reg *regs) { + regs->r_fs = tp->tf_fs; regs->r_es = tp->tf_es; regs->r_ds = tp->tf_ds; @@ -2832,6 +2833,8 @@ fill_frame_regs(struct trapframe *tp, struct reg *regs regs->r_eflags = tp->tf_eflags; regs->r_esp = tp->tf_esp; regs->r_ss = tp->tf_ss; + regs->r_err = 0; + regs->r_trapno = 0; return (0); } Modified: stable/12/sys/kern/sys_process.c ============================================================================== --- stable/12/sys/kern/sys_process.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/kern/sys_process.c Tue Dec 4 19:06:11 2018 (r341490) @@ -541,6 +541,9 @@ struct ptrace_args { * copyin(uap->addr, &r.reg32, sizeof r.reg32); * .. except this is done at runtime. */ +#define BZERO(a, s) wrap32 ? \ + bzero(a ## 32, s ## 32) : \ + bzero(a, s) #define COPYIN(u, k, s) wrap32 ? \ copyin(u, k ## 32, s ## 32) : \ copyin(u, k, s) @@ -548,6 +551,7 @@ struct ptrace_args { copyout(k ## 32, u, s ## 32) : \ copyout(k, u, s) #else +#define BZERO(a, s) bzero(a, s) #define COPYIN(u, k, s) copyin(u, k, s) #define COPYOUT(k, u, s) copyout(k, u, s) #endif @@ -573,7 +577,7 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap) struct ptrace_lwpinfo32 pl32; struct ptrace_vm_entry32 pve32; #endif - char args[nitems(td->td_sa.args) * sizeof(register_t)]; + char args[sizeof(td->td_sa.args)]; int ptevents; } r; void *addr; @@ -590,11 +594,17 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap) addr = &r; switch (uap->req) { case PT_GET_EVENT_MASK: + case PT_LWPINFO: + case PT_GET_SC_ARGS: + break; case PT_GETREGS: + BZERO(&r.reg, sizeof r.reg); + break; case PT_GETFPREGS: + BZERO(&r.fpreg, sizeof r.fpreg); + break; case PT_GETDBREGS: - case PT_LWPINFO: - case PT_GET_SC_ARGS: + BZERO(&r.dbreg, sizeof r.dbreg); break; case PT_SETREGS: error = COPYIN(uap->addr, &r.reg, sizeof r.reg); @@ -662,6 +672,7 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap) } #undef COPYIN #undef COPYOUT +#undef BZERO #ifdef COMPAT_FREEBSD32 /* Modified: stable/12/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/12/sys/sparc64/sparc64/machdep.c Tue Dec 4 18:51:28 2018 (r341489) +++ stable/12/sys/sparc64/sparc64/machdep.c Tue Dec 4 19:06:11 2018 (r341490) @@ -1056,6 +1056,7 @@ fill_fpregs(struct thread *td, struct fpreg *fpregs) bcopy(pcb->pcb_ufp, fpregs->fr_regs, sizeof(fpregs->fr_regs)); fpregs->fr_fsr = tf->tf_fsr; fpregs->fr_gsr = tf->tf_gsr; + fpregs->fr_pad[0] = 0; return (0); }