From d5b3fb43d9c03533a0306a5a2bfd822adcb8866c Mon Sep 17 00:00:00 2001 From: mvs Date: Wed, 2 Jun 2021 11:30:23 +0000 Subject: [PATCH] Unlock setrtable(2). Local copy of `ps_rtableid' used to make checks consistent. ok mpi@ --- sys/kern/syscalls.master | 4 ++-- sys/kern/uipc_syscalls.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 63d8bf01377..8d45940ac62 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.216 2021/05/12 15:04:48 mpi Exp $ +; $OpenBSD: syscalls.master,v 1.217 2021/06/02 11:30:23 mvs Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -533,7 +533,7 @@ 307 OBSOL statfs53 308 OBSOL fstatfs53 309 OBSOL fhstatfs53 -310 STD { int sys_setrtable(int rtableid); } +310 STD NOLOCK { int sys_setrtable(int rtableid); } 311 STD NOLOCK { int sys_getrtable(void); } 312 OBSOL t32_getdirentries 313 STD { int sys_faccessat(int fd, const char *path, \ diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index b28c66ac69b..2221798eba5 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.191 2021/05/28 16:24:53 visa Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.192 2021/06/02 11:30:23 mvs Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -1171,13 +1171,14 @@ sys_setrtable(struct proc *p, void *v, register_t *retval) struct sys_setrtable_args /* { syscallarg(int) rtableid; } */ *uap = v; + u_int ps_rtableid = p->p_p->ps_rtableid; int rtableid, error; rtableid = SCARG(uap, rtableid); - if (p->p_p->ps_rtableid == (u_int)rtableid) + if (ps_rtableid == rtableid) return (0); - if (p->p_p->ps_rtableid != 0 && (error = suser(p)) != 0) + if (ps_rtableid != 0 && (error = suser(p)) != 0) return (error); if (rtableid < 0 || !rtable_exists((u_int)rtableid)) return (EINVAL); -- 2.20.1