1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-06 09:17:25 +00:00

Avoid writing uninitialized stack data into a thread's MMX/SSE state by

first getting the current state with td_thr_getxmmregs_p.  Without this,
debugging a threaded app that uses libthr resulted in kernel panics or
spurious SIGFPEs for me.

(As of revision 1.6, sys/i386/i386/ptrace_machdep.c masks off the
reserved bits in the mxcsr register, which prevents the kernel panics.)

Architectures without PT_GETXMMREGS are not affected.

MFC after:      1 week
This commit is contained in:
Ed Maste 2007-02-20 18:10:13 +00:00
parent 560a65051c
commit 5a16cfaeb6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=166851

View File

@ -961,18 +961,21 @@ fbsd_thread_store_registers (int regno)
err = td_thr_getgregs_p (&th, gregset);
if (err != TD_OK)
error ("%s: td_thr_getgregs %s", __func__, thread_db_err_str (err));
err = td_thr_getfpregs_p (&th, &fpregset);
#ifdef PT_GETXMMREGS
err = td_thr_getxmmregs_p (&th, xmmregs);
if (err != TD_OK)
error ("%s: td_thr_getfpgregs %s", __func__, thread_db_err_str (err));
{
#endif
err = td_thr_getfpregs_p (&th, &fpregset);
if (err != TD_OK)
error ("%s: td_thr_getfpgregs %s", __func__, thread_db_err_str (err));
#ifdef PT_GETXMMREGS
}
#endif
supply_register (regno, old_value);
}
fill_gregset (gregset, regno);
fill_fpregset (&fpregset, regno);
#ifdef PT_GETXMMREGS
i387_fill_fxsave (xmmregs, regno);
#endif
err = td_thr_setgregs_p (&th, gregset);
if (err != TD_OK)
error ("Cannot store general-purpose registers for thread %d: Thread ID=%d, %s",
@ -980,11 +983,13 @@ fbsd_thread_store_registers (int regno)
thread_db_err_str (err));
#ifdef PT_GETXMMREGS
i387_fill_fxsave (xmmregs, regno);
err = td_thr_setxmmregs_p (&th, xmmregs);
if (err == TD_OK)
return;
#endif
fill_fpregset (&fpregset, regno);
err = td_thr_setfpregs_p (&th, &fpregset);
if (err != TD_OK)
error ("Cannot store floating-point registers for thread %d: Thread ID=%d, %s",