From owner-freebsd-net@freebsd.org Tue Apr 11 22:25:14 2017 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E34E4D3A31C for ; Tue, 11 Apr 2017 22:25:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D2B0B2C3 for ; Tue, 11 Apr 2017 22:25:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v3BMPDhD051684 for ; Tue, 11 Apr 2017 22:25:14 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-net@FreeBSD.org Subject: [Bug 131876] [socket] FD leak by receiving SCM_RIGHTS by recvmsg with small control message buffer Date: Tue, 11 Apr 2017 22:25:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 6.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: markj@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: freebsd-net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to cc bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 22:25:15 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D131876 Mark Johnston changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|rwatson@FreeBSD.org |freebsd-net@FreeBSD.org CC| |markj@FreeBSD.org Status|In Progress |Open --- Comment #3 from Mark Johnston --- It looks to me as though the loop in kern_recvit() which sets MSG_CTRUNC ne= eds to use dom_dispose to ensure that the remaining rights are closed before the mbuf is freed. Unfortunately, dom_dispose wants a socket rather than an mbuf - this= was changed in r285522 to fix a race between unp_dispose() and unp_gc(). Howeve= r, in this case the truncated mbuf will have already been removed from the soc= ket buffer, so we don't need to worry about the race. (If MSG_PEEK is set, the rights will still be present in the sockbuf and we needn't do anything.) So, to fix this we'd either need a way to invoke dom_dispose on a plain mbuf (i.e., the KPI prior to r285522), or we need to fake up a socket like sorflush() does. --=20 You are receiving this mail because: You are the assignee for the bug.=