Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.118.2.1 retrieving revision 1.122.4.3 diff -u -p -r1.118.2.1 -r1.122.4.3 --- src/sys/kern/uipc_socket.c 2006/06/19 04:07:16 1.118.2.1 +++ src/sys/kern/uipc_socket.c 2007/02/01 08:48:39 1.122.4.3 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.118.2.1 2006/06/19 04:07:16 chap Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.122.4.3 2007/02/01 08:48:39 ad Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.118.2.1 2006/06/19 04:07:16 chap Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.122.4.3 2007/02/01 08:48:39 ad Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -130,9 +130,9 @@ EVCNT_ATTACH_STATIC(sosend_kvalimit); static struct callback_entry sokva_reclaimerentry; #ifdef SOSEND_NO_LOAN -int use_sosend_loan = 0; +int sock_loan_thresh = -1; #else -int use_sosend_loan = 1; +int sock_loan_thresh = 4096; #endif static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; @@ -145,7 +145,6 @@ int somaxkva = SOMAXKVA; static int socurkva; static int sokvawaiters; -#define SOCK_LOAN_THRESH 4096 #define SOCK_LOAN_CHUNK 65536 static size_t sodopendfree(void); @@ -474,6 +473,12 @@ socreate(int dom, struct socket **aso, i uid_t uid; int error, s; + error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_SOCKET, + KAUTH_REQ_NETWORK_SOCKET_OPEN, KAUTH_ARG(dom), KAUTH_ARG(type), + KAUTH_ARG(proto)); + if (error) + return (error); + if (proto) prp = pffindproto(dom, proto, type); else @@ -506,7 +511,7 @@ socreate(int dom, struct socket **aso, i so->so_mowner = &prp->pr_domain->dom_mowner; #endif if (l != NULL) { - uid = kauth_cred_geteuid(l->l_proc->p_cred); + uid = kauth_cred_geteuid(l->l_cred); } else { uid = 0; } @@ -853,9 +858,9 @@ sosend(struct socket *so, struct mbuf *a mlen = MLEN; } MCLAIM(m, so->so_snd.sb_mowner); - if (use_sosend_loan && - uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && - space >= SOCK_LOAN_THRESH && + if (sock_loan_thresh >= 0 && + uio->uio_iov->iov_len >= sock_loan_thresh && + space >= sock_loan_thresh && (len = sosend_loan(so, uio, m, space)) != 0) { SOSEND_COUNTER_INCR(&sosend_loan_big); @@ -1418,6 +1423,7 @@ sosetopt(struct socket *so, int level, i { int error; struct mbuf *m; + struct linger *l; error = 0; m = m0; @@ -1434,13 +1440,18 @@ sosetopt(struct socket *so, int level, i error = EINVAL; goto bad; } - if (mtod(m, struct linger *)->l_linger < 0 || - mtod(m, struct linger *)->l_linger > (INT_MAX / hz)) { + l = mtod(m, struct linger *); + if (l->l_linger < 0 || l->l_linger > USHRT_MAX || + l->l_linger > (INT_MAX / hz)) { error = EDOM; goto bad; } - so->so_linger = mtod(m, struct linger *)->l_linger; - /* fall thru... */ + so->so_linger = l->l_linger; + if (l->l_onoff) + so->so_options |= SO_LINGER; + else + so->so_options &= ~SO_LINGER; + break; case SO_DEBUG: case SO_KEEPALIVE: @@ -1580,7 +1591,7 @@ sogetopt(struct socket *so, int level, i case SO_LINGER: m->m_len = sizeof(struct linger); mtod(m, struct linger *)->l_onoff = - so->so_options & SO_LINGER; + (so->so_options & SO_LINGER) ? 1 : 0; mtod(m, struct linger *)->l_linger = so->so_linger; break; @@ -1593,7 +1604,7 @@ sogetopt(struct socket *so, int level, i case SO_BROADCAST: case SO_OOBINLINE: case SO_TIMESTAMP: - *mtod(m, int *) = so->so_options & optname; + *mtod(m, int *) = (so->so_options & optname) ? 1 : 0; break; case SO_TYPE: