Remove PROC_CHECK_PRIV macro from sys_process.c
Just put the priv_check calls in the code. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D56864
This commit is contained in:
+40
-19
@@ -72,13 +72,6 @@
|
|||||||
/* Assert it's safe to unlock a process, e.g. to allocate working memory */
|
/* Assert it's safe to unlock a process, e.g. to allocate working memory */
|
||||||
#define PROC_ASSERT_TRACEREQ(p) MPASS(((p)->p_flag2 & P2_PTRACEREQ) != 0)
|
#define PROC_ASSERT_TRACEREQ(p) MPASS(((p)->p_flag2 & P2_PTRACEREQ) != 0)
|
||||||
|
|
||||||
#define PROC_PRIV_CHECK(priv) do { \
|
|
||||||
int _error; \
|
|
||||||
_error = priv_check(curthread, priv); \
|
|
||||||
if (_error) \
|
|
||||||
return (_error); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions implemented below:
|
* Functions implemented below:
|
||||||
*
|
*
|
||||||
@@ -115,8 +108,12 @@ proc_read_regs(struct thread *td, struct reg *regs)
|
|||||||
int
|
int
|
||||||
proc_write_regs(struct thread *td, struct reg *regs)
|
proc_write_regs(struct thread *td, struct reg *regs)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
return (set_regs(td, regs));
|
return (set_regs(td, regs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +127,12 @@ proc_read_dbregs(struct thread *td, struct dbreg *dbregs)
|
|||||||
int
|
int
|
||||||
proc_write_dbregs(struct thread *td, struct dbreg *dbregs)
|
proc_write_dbregs(struct thread *td, struct dbreg *dbregs)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
return (set_dbregs(td, dbregs));
|
return (set_dbregs(td, dbregs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +150,12 @@ proc_read_fpregs(struct thread *td, struct fpreg *fpregs)
|
|||||||
int
|
int
|
||||||
proc_write_fpregs(struct thread *td, struct fpreg *fpregs)
|
proc_write_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
return (set_fpregs(td, fpregs));
|
return (set_fpregs(td, fpregs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +276,9 @@ proc_write_regset(struct thread *td, int note, struct iovec *iov)
|
|||||||
if (regset->set == NULL)
|
if (regset->set == NULL)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
p = td->td_proc;
|
p = td->td_proc;
|
||||||
|
|
||||||
@@ -305,8 +312,12 @@ proc_read_regs32(struct thread *td, struct reg32 *regs32)
|
|||||||
int
|
int
|
||||||
proc_write_regs32(struct thread *td, struct reg32 *regs32)
|
proc_write_regs32(struct thread *td, struct reg32 *regs32)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
return (set_regs32(td, regs32));
|
return (set_regs32(td, regs32));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,8 +331,12 @@ proc_read_dbregs32(struct thread *td, struct dbreg32 *dbregs32)
|
|||||||
int
|
int
|
||||||
proc_write_dbregs32(struct thread *td, struct dbreg32 *dbregs32)
|
proc_write_dbregs32(struct thread *td, struct dbreg32 *dbregs32)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
return (set_dbregs32(td, dbregs32));
|
return (set_dbregs32(td, dbregs32));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,8 +350,12 @@ proc_read_fpregs32(struct thread *td, struct fpreg32 *fpregs32)
|
|||||||
int
|
int
|
||||||
proc_write_fpregs32(struct thread *td, struct fpreg32 *fpregs32)
|
proc_write_fpregs32(struct thread *td, struct fpreg32 *fpregs32)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED);
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
return (set_fpregs32(td, fpregs32));
|
return (set_fpregs32(td, fpregs32));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -378,7 +397,9 @@ proc_rwmem(struct proc *p, struct uio *uio)
|
|||||||
fault_flags = writing ? VM_FAULT_DIRTY : VM_FAULT_NORMAL;
|
fault_flags = writing ? VM_FAULT_DIRTY : VM_FAULT_NORMAL;
|
||||||
|
|
||||||
if (writing) {
|
if (writing) {
|
||||||
PROC_PRIV_CHECK(PRIV_PROC_MEM_WRITE);
|
error = priv_check(curthread, PRIV_PROC_MEM_WRITE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -710,11 +731,11 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap)
|
|||||||
addr = uap->addr;
|
addr = uap->addr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (error)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
error = kern_ptrace(td, uap->req, uap->pid, addr, uap->data);
|
error = kern_ptrace(td, uap->req, uap->pid, addr, uap->data);
|
||||||
if (error)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
switch (uap->req) {
|
switch (uap->req) {
|
||||||
@@ -1250,7 +1271,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
|||||||
CTR3(KTR_PTRACE, "PT_STEP: tid %d (pid %d), sig = %d",
|
CTR3(KTR_PTRACE, "PT_STEP: tid %d (pid %d), sig = %d",
|
||||||
td2->td_tid, p->p_pid, data);
|
td2->td_tid, p->p_pid, data);
|
||||||
error = ptrace_single_step(td2);
|
error = ptrace_single_step(td2);
|
||||||
if (error)
|
if (error != 0)
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
case PT_CONTINUE:
|
case PT_CONTINUE:
|
||||||
@@ -1260,7 +1281,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
|||||||
if (addr != (void *)1) {
|
if (addr != (void *)1) {
|
||||||
error = ptrace_set_pc(td2,
|
error = ptrace_set_pc(td2,
|
||||||
(u_long)(uintfptr_t)addr);
|
(u_long)(uintfptr_t)addr);
|
||||||
if (error)
|
if (error != 0)
|
||||||
goto out;
|
goto out;
|
||||||
td2->td_dbgflags |= TDB_USERWR;
|
td2->td_dbgflags |= TDB_USERWR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user