Skip to content

Commit

Permalink
Prevent kernel stack disclosure in getcontext/swapcontext
Browse files Browse the repository at this point in the history
Expand r338982 to cover freebsd32 interfaces on amd64, mips, and powerpc.

MFC after:	2 days
Security:	FreeBSD-EN-18:12.mem
Security:	CVE-2018-17155
Sponsored by:	Dell EMC Isilon
  • Loading branch information
vangyzen committed Nov 26, 2018
1 parent 17083af commit ca2c736
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/amd64/ia32/ia32_signal.c
Expand Up @@ -261,6 +261,7 @@ freebsd32_getcontext(struct thread *td, struct freebsd32_getcontext_args *uap)
if (uap->ucp == NULL)
ret = EINVAL;
else {
bzero(&uc, sizeof(uc));
ia32_get_mcontext(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
Expand Down Expand Up @@ -301,6 +302,7 @@ freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap)
if (uap->oucp == NULL || uap->ucp == NULL)
ret = EINVAL;
else {
bzero(&uc, sizeof(uc));
ia32_get_mcontext(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
Expand Down
2 changes: 2 additions & 0 deletions sys/mips/mips/freebsd32_machdep.c
Expand Up @@ -294,6 +294,7 @@ freebsd32_getcontext(struct thread *td, struct freebsd32_getcontext_args *uap)
if (uap->ucp == NULL)
ret = EINVAL;
else {
bzero(&uc, sizeof(uc));
get_mcontext32(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
Expand Down Expand Up @@ -333,6 +334,7 @@ freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap)
if (uap->oucp == NULL || uap->ucp == NULL)
ret = EINVAL;
else {
bzero(&uc, sizeof(uc));
get_mcontext32(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
Expand Down
2 changes: 2 additions & 0 deletions sys/powerpc/powerpc/exec_machdep.c
Expand Up @@ -785,6 +785,7 @@ freebsd32_getcontext(struct thread *td, struct freebsd32_getcontext_args *uap)
if (uap->ucp == NULL)
ret = EINVAL;
else {
bzero(&uc, sizeof(uc));
get_mcontext32(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
Expand Down Expand Up @@ -824,6 +825,7 @@ freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap)
if (uap->oucp == NULL || uap->ucp == NULL)
ret = EINVAL;
else {
bzero(&uc, sizeof(uc));
get_mcontext32(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
Expand Down

0 comments on commit ca2c736

Please sign in to comment.