From: mpi Date: Tue, 9 Jan 2018 15:14:23 +0000 (+0000) Subject: Change `so_state' and `so_error' to unsigned int such that they can X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=69dc22ffae4c8d27b6c8f9bd485b31751844294b;p=openbsd Change `so_state' and `so_error' to unsigned int such that they can be atomically read from any context. ok bluhm@, visa@ --- diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 3586720d0ad..af56c42095d 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.227 2018/01/08 11:54:28 mpi Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.228 2018/01/09 15:14:23 mpi Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -1337,7 +1337,7 @@ pledge_sockopt(struct proc *p, int set, int level, int optname) } int -pledge_socket(struct proc *p, int domain, int state) +pledge_socket(struct proc *p, int domain, unsigned int state) { if (! ISSET(p->p_p->ps_flags, PS_PLEDGE)) return 0; diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 494b057624c..c653a258254 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.213 2018/01/02 12:54:07 mpi Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.214 2018/01/09 15:14:23 mpi Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -1248,7 +1248,7 @@ somove(struct socket *so, int wait) u_long len, off, oobmark; long space; int error = 0, maxreached = 0; - short state; + unsigned int state; soassertlocked(so); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 86f2b5603bb..75918cc2f69 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.161 2018/01/02 06:38:45 guenther Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.162 2018/01/09 15:14:23 mpi Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -83,7 +83,8 @@ sys_socket(struct proc *p, void *v, register_t *retval) struct file *fp; int type = SCARG(uap, type); int domain = SCARG(uap, domain); - int fd, error, ss = 0; + int fd, error; + unsigned int ss = 0; if ((type & SOCK_DNS) && !(domain == AF_INET || domain == AF_INET6)) return (EINVAL); diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 02fdf2069f1..cc2b23e0661 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.162 2017/12/01 10:33:33 bluhm Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.163 2018/01/09 15:14:23 mpi Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -583,7 +583,7 @@ tcp_attach(struct socket *so, int proto) inp = sotoinpcb(so); tp = tcp_newtcpcb(inp); if (tp == NULL) { - int nofd = so->so_state & SS_NOFDREF; /* XXX */ + unsigned int nofd = so->so_state & SS_NOFDREF; /* XXX */ so->so_state &= ~SS_NOFDREF; /* don't free the socket yet */ in_pcbdetach(inp); diff --git a/sys/sys/pledge.h b/sys/sys/pledge.h index 832f170e146..ef88d56ba15 100644 --- a/sys/sys/pledge.h +++ b/sys/sys/pledge.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pledge.h,v 1.33 2017/12/12 01:12:34 deraadt Exp $ */ +/* $OpenBSD: pledge.h,v 1.34 2018/01/09 15:14:23 mpi Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -126,7 +126,7 @@ int pledge_chown(struct proc *p, uid_t, gid_t); int pledge_adjtime(struct proc *p, const void *v); int pledge_sendit(struct proc *p, const void *to); int pledge_sockopt(struct proc *p, int set, int level, int optname); -int pledge_socket(struct proc *p, int domain, int state); +int pledge_socket(struct proc *p, int domain, unsigned int state); int pledge_ioctl(struct proc *p, long com, struct file *); int pledge_ioctl_drm(struct proc *p, long com, dev_t device); int pledge_ioctl_vmm(struct proc *p, long com); diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 00c344ffc66..097ae3a4ab9 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socketvar.h,v 1.81 2018/01/02 12:54:07 mpi Exp $ */ +/* $OpenBSD: socketvar.h,v 1.82 2018/01/09 15:14:23 mpi Exp $ */ /* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */ /*- @@ -51,12 +51,12 @@ TAILQ_HEAD(soqhead, socket); * private data and error information. */ struct socket { + const struct protosw *so_proto; /* protocol handle */ + void *so_pcb; /* protocol control block */ + u_int so_state; /* internal state flags SS_*, below */ short so_type; /* generic type, see socket.h */ short so_options; /* from socket call, see socket.h */ short so_linger; /* time to linger while closing */ - short so_state; /* internal state flags SS_*, below */ - void *so_pcb; /* protocol control block */ - const struct protosw *so_proto; /* protocol handle */ /* * Variables for connection queueing. * Socket where accepts occur is so_head in all subsidiary sockets. @@ -77,7 +77,7 @@ struct socket { short so_qlen; /* number of connections on so_q */ short so_qlimit; /* max number queued connections */ short so_timeo; /* connection timeout */ - u_short so_error; /* error affecting connection */ + u_int so_error; /* error affecting connection */ pid_t so_pgid; /* pgid for signals */ uid_t so_siguid; /* uid of process who set so_pgid */ uid_t so_sigeuid; /* euid of process who set so_pgid */ @@ -190,10 +190,6 @@ static inline long sbspace(struct socket *so, struct sockbuf *sb) { KASSERT(sb == &so->so_rcv || sb == &so->so_snd); -#if 0 - /* XXXSMP kqueue_scan() calling filt_sowrite() cannot sleep. */ - soassertlocked(so); -#endif return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt); }