In syscall, always make a copy of parameters from trapframe, this
becauses some syscalls using set_mcontext can sneakily change parameters and later when those syscalls references parameters, they will wrongly use register values in mcontext_t. Approved by: peter
This commit is contained in:
parent
60a1dcedb7
commit
9ec724bfc3
@ -729,21 +729,18 @@ syscall(frame)
|
||||
/*
|
||||
* copyin and the ktrsyscall()/ktrsysret() code is MP-aware
|
||||
*/
|
||||
if (narg <= regcnt) {
|
||||
argp = &frame.tf_rdi;
|
||||
argp += reg;
|
||||
error = 0;
|
||||
} else {
|
||||
KASSERT(narg <= sizeof(args) / sizeof(args[0]),
|
||||
("Too many syscall arguments!"));
|
||||
KASSERT(narg <= sizeof(args) / sizeof(args[0]),
|
||||
("Too many syscall arguments!"));
|
||||
error = 0;
|
||||
argp = &frame.tf_rdi;
|
||||
argp += reg;
|
||||
bcopy(argp, args, sizeof(args[0]) * regcnt);
|
||||
if (narg > regcnt) {
|
||||
KASSERT(params != NULL, ("copyin args with no params!"));
|
||||
argp = &frame.tf_rdi;
|
||||
argp += reg;
|
||||
bcopy(argp, args, sizeof(args[0]) * regcnt);
|
||||
error = copyin(params, &args[regcnt],
|
||||
(narg - regcnt) * sizeof(args[0]));
|
||||
argp = &args[0];
|
||||
(narg - regcnt) * sizeof(args[0]));
|
||||
}
|
||||
argp = &args[0];
|
||||
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(td, KTR_SYSCALL))
|
||||
|
Loading…
Reference in New Issue
Block a user