diff options
author | 2016-11-21 09:09:06 +0000 | |
---|---|---|
committer | 2016-11-21 09:09:06 +0000 | |
commit | c0a948f7c8b9efc397a8fe27dfddb23b9526a162 (patch) | |
tree | be004bac1aba024cc718164e63e5804d134a229d /sys/kern/sys_socket.c | |
parent | Include the OFP header of the message that caused the error on error (diff) | |
download | wireguard-openbsd-c0a948f7c8b9efc397a8fe27dfddb23b9526a162.tar.xz wireguard-openbsd-c0a948f7c8b9efc397a8fe27dfddb23b9526a162.zip |
Enforce that pr_usrreq functions are called at IPL_SOFTNET.
This will allow us to keep locking simple as soon as we trade
splsoftnet() for a rwlock.
ok bluhm@, claudio@
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r-- | sys/kern/sys_socket.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 7a90f780067..1ed6dff439c 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_socket.c,v 1.22 2016/10/06 17:02:10 bluhm Exp $ */ +/* $OpenBSD: sys_socket.c,v 1.23 2016/11/21 09:09:06 mpi Exp $ */ /* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */ /* @@ -73,6 +73,7 @@ int soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) { struct socket *so = (struct socket *)fp->f_data; + int s, error = 0; switch (cmd) { @@ -122,8 +123,12 @@ soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) return (ifioctl(so, cmd, data, p)); if (IOCGROUP(cmd) == 'r') return (rtioctl(cmd, data, p)); - return ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, + s = splsoftnet(); + error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)NULL, p)); + splx(s); + + return (error); } int @@ -167,6 +172,7 @@ int soo_stat(struct file *fp, struct stat *ub, struct proc *p) { struct socket *so = fp->f_data; + int s; memset(ub, 0, sizeof (*ub)); ub->st_mode = S_IFSOCK; @@ -177,8 +183,10 @@ soo_stat(struct file *fp, struct stat *ub, struct proc *p) ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; ub->st_uid = so->so_euid; ub->st_gid = so->so_egid; + s = splsoftnet(); (void) ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, (struct mbuf *)ub, NULL, NULL, p)); + splx(s); return (0); } |