sysarch: improve checks for max user address

(cherry picked from commit 666303f5980896346c455bc949e49952220d02b7)
This commit is contained in:
Konstantin Belousov 2024-09-16 22:55:06 +03:00
parent 1ed40b4506
commit 73f2b9f05a

View file

@ -48,6 +48,7 @@
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/smp.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/uio.h>
@ -316,7 +317,7 @@ sysarch(struct thread *td, struct sysarch_args *uap)
case AMD64_SET_FSBASE:
error = copyin(uap->parms, &a64base, sizeof(a64base));
if (error == 0) {
if (a64base < VM_MAXUSER_ADDRESS) {
if (a64base < curproc->p_sysent->sv_maxuser) {
set_pcb_flags(pcb, PCB_FULL_IRET);
pcb->pcb_fsbase = a64base;
td->td_frame->tf_fs = _ufssel;
@ -334,7 +335,7 @@ sysarch(struct thread *td, struct sysarch_args *uap)
case AMD64_SET_GSBASE:
error = copyin(uap->parms, &a64base, sizeof(a64base));
if (error == 0) {
if (a64base < VM_MAXUSER_ADDRESS) {
if (a64base < curproc->p_sysent->sv_maxuser) {
set_pcb_flags(pcb, PCB_FULL_IRET);
pcb->pcb_gsbase = a64base;
td->td_frame->tf_gs = _ugssel;