The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e7f369b1c18ca0377bb0b016b4cab3f0de2a74c5

commit e7f369b1c18ca0377bb0b016b4cab3f0de2a74c5
Author:     Andrew Turner <and...@freebsd.org>
AuthorDate: 2021-06-14 11:01:46 +0000
Commit:     Andrew Turner <and...@freebsd.org>
CommitDate: 2021-06-14 14:53:10 +0000

    Use the correct length when copying arm64 vfp registers
    
    We passed the wrong length into memcpy in the arm64 get_fpcontext and
    set_fpcontext. This caused us to copy two status registers we didn't
    expect to copy.
    
    These are safe as they exist in both the source and destination, although
    in a different order, and we copy the correct values after the memcpy.
    
    Obtained from:  CheriBSD
    Sponsored by:   Innovate UK
---
 sys/arm64/arm64/machdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 71aa45b47d59..82a77ce184d8 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -650,7 +650,7 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
                KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
                    ("Non-userspace FPU flags set in get_fpcontext"));
                memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs,
-                   sizeof(mcp->mc_fpregs));
+                   sizeof(mcp->mc_fpregs.fp_q));
                mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr;
                mcp->mc_fpregs.fp_sr = curpcb->pcb_fpustate.vfp_fpsr;
                mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags;
@@ -681,7 +681,7 @@ set_fpcontext(struct thread *td, mcontext_t *mcp)
                KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate,
                    ("Called set_fpcontext while the kernel is using the VFP"));
                memcpy(curpcb->pcb_fpustate.vfp_regs, mcp->mc_fpregs.fp_q,
-                   sizeof(mcp->mc_fpregs));
+                   sizeof(mcp->mc_fpregs.fp_q));
                curpcb->pcb_fpustate.vfp_fpcr = mcp->mc_fpregs.fp_cr;
                curpcb->pcb_fpustate.vfp_fpsr = mcp->mc_fpregs.fp_sr;
                curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK;
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to