Date: Sat, 16 Sep 2017 02:32:00 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323634 - stable/11/sys/kern Message-ID: <201709160232.v8G2W0PW006037@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Sat Sep 16 02:32:00 2017 New Revision: 323634 URL: https://svnweb.freebsd.org/changeset/base/323634 Log: Merge r323552: Fix two issues with not ready data in sockets (read: sendfile) in UNIX sockets. o Check that socket is still connected in uipc_ready(). If not we are responsible to free mbufs. o In uipc_send() if socket appears to be disconnected, but we are sending data with pending I/Os, don't free mbufs. PR: 222259 Modified: stable/11/sys/kern/uipc_usrreq.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/uipc_usrreq.c ============================================================================== --- stable/11/sys/kern/uipc_usrreq.c Sat Sep 16 02:10:36 2017 (r323633) +++ stable/11/sys/kern/uipc_usrreq.c Sat Sep 16 02:32:00 2017 (r323634) @@ -1056,7 +1056,11 @@ uipc_send(struct socket *so, int flags, struct mbuf *m release: if (control != NULL) m_freem(control); - if (m != NULL) + /* + * In case of PRUS_NOTREADY, uipc_ready() is responsible + * for freeing memory. + */ + if (m != NULL && (flags & PRUS_NOTREADY) == 0) m_freem(m); return (error); } @@ -1071,7 +1075,12 @@ uipc_ready(struct socket *so, struct mbuf *m, int coun unp = sotounpcb(so); UNP_LINK_RLOCK(); - unp2 = unp->unp_conn; + if ((unp2 = unp->unp_conn) == NULL) { + UNP_LINK_RUNLOCK(); + for (int i = 0; i < count; i++) + m = m_free(m); + return (ECONNRESET); + } UNP_PCB_LOCK(unp2); so2 = unp2->unp_socket;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709160232.v8G2W0PW006037>