summaryrefslogtreecommitdiff
path: root/sys/nfs
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-09-01 15:05:32 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-09-01 15:05:32 +0000
commit12f74acdeb1b3c509e5d628e1e838e1738ea082a (patch)
treeb1cddabdd93422bcd10172a3790c6a941ac6e4bd /sys/nfs
parentaebafd059da2974a1bcbe5ec8c474a8c881b8ca9 (diff)
Change sosetopt() to no longer free the mbuf it receives and change
all the callers to call m_freem(9). Support from deraadt@ and tedu@, ok visa@, bluhm@
Diffstat (limited to 'sys/nfs')
-rw-r--r--sys/nfs/krpc_subr.c6
-rw-r--r--sys/nfs/nfs_socket.c6
-rw-r--r--sys/nfs/nfs_syscalls.c4
3 files changed, 13 insertions, 3 deletions
diff --git a/sys/nfs/krpc_subr.c b/sys/nfs/krpc_subr.c
index 3e073388c4e..346ff9ec989 100644
--- a/sys/nfs/krpc_subr.c
+++ b/sys/nfs/krpc_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: krpc_subr.c,v 1.31 2017/08/10 19:20:43 mpi Exp $ */
+/* $OpenBSD: krpc_subr.c,v 1.32 2017/09/01 15:05:31 mpi Exp $ */
/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */
/*
@@ -242,6 +242,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
s = solock(so);
error = sosetopt(so, SOL_SOCKET, SO_RCVTIMEO, m);
sounlock(s);
+ m_freem(m);
if (error)
goto out;
@@ -257,6 +258,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
s = solock(so);
error = sosetopt(so, SOL_SOCKET, SO_BROADCAST, m);
sounlock(s);
+ m_freem(m);
if (error)
goto out;
}
@@ -273,6 +275,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
s = solock(so);
error = sosetopt(so, IPPROTO_IP, IP_PORTRANGE, mopt);
sounlock(s);
+ m_freem(mopt);
if (error)
goto out;
@@ -299,6 +302,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
s = solock(so);
error = sosetopt(so, IPPROTO_IP, IP_PORTRANGE, mopt);
sounlock(s);
+ m_freem(mopt);
if (error)
goto out;
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 2251b6fbf55..1b52fe1d804 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_socket.c,v 1.125 2017/08/14 16:56:57 tedu Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.126 2017/09/01 15:05:31 mpi Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
@@ -270,6 +270,7 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep)
s = solock(so);
error = sosetopt(so, IPPROTO_IP, IP_PORTRANGE, mopt);
sounlock(s);
+ m_freem(mopt);
if (error)
goto bad;
@@ -294,6 +295,7 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep)
s = solock(so);
error = sosetopt(so, IPPROTO_IP, IP_PORTRANGE, mopt);
sounlock(s);
+ m_freem(mopt);
if (error)
goto bad;
}
@@ -358,12 +360,14 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep)
*mtod(m, int32_t *) = 1;
m->m_len = sizeof(int32_t);
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
+ m_freem(m);
}
if (so->so_proto->pr_protocol == IPPROTO_TCP) {
MGET(m, M_WAIT, MT_SOOPTS);
*mtod(m, int32_t *) = 1;
m->m_len = sizeof(int32_t);
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
+ m_freem(m);
}
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index 2e92ecad6c6..0f98a30d39d 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.110 2017/08/09 14:22:58 mpi Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.111 2017/09/01 15:05:31 mpi Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -265,6 +265,7 @@ nfssvc_addsock(struct file *fp, struct mbuf *mynam)
*mtod(m, int32_t *) = 1;
m->m_len = sizeof(int32_t);
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
+ m_freem(m);
}
if (so->so_proto->pr_domain->dom_family == AF_INET &&
so->so_proto->pr_protocol == IPPROTO_TCP) {
@@ -272,6 +273,7 @@ nfssvc_addsock(struct file *fp, struct mbuf *mynam)
*mtod(m, int32_t *) = 1;
m->m_len = sizeof(int32_t);
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
+ m_freem(m);
}
so->so_rcv.sb_flags &= ~SB_NOINTR;
so->so_rcv.sb_timeo = 0;