From owner-freebsd-bugs@freebsd.org Thu Jul 20 17:53:53 2017 Return-Path: Delivered-To: freebsd-bugs@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 DE852C7D0BC for ; Thu, 20 Jul 2017 17:53:53 +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 BFE7B721DB for ; Thu, 20 Jul 2017 17:53:53 +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 v6KHrrbQ074500 for ; Thu, 20 Jul 2017 17:53:53 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 220888] [panic][patch] Race between ngs_rcvdata() and soclose() Date: Thu, 20 Jul 2017 17:53:53 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: patch X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: kxie@xiplink.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status keywords bug_severity priority component assigned_to reporter attachments.created Message-ID: 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-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jul 2017 17:53:54 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D220888 Bug ID: 220888 Summary: [panic][patch] Race between ngs_rcvdata() and soclose() Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Keywords: patch Severity: Affects Only Me Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: kxie@xiplink.com Keywords: patch Created attachment 184554 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D184554&action= =3Dedit prevent race in ng_socket Recently we got some "Fatal trap 12" panics when the userland processes whi= ch used ng_socket to communicate got killed. The panics happened in ng_queue a= nd the backtrace is Tracing pid 12 tid 100009 td 0xfffffe0001514490 _mtx_lock_sleep() at _mtx_lock_sleep+0x70/frame 0xffffff800025a700 _mtx_lock_flags() at _mtx_lock_flags+0x4d/frame 0xffffff800025a710 ngs_rcvdata() at ngs_rcvdata+0xfa/frame 0xffffff800025a870 ng_apply_item() at ng_apply_item+0x1f2/frame 0xffffff800025a970 ngthread() at ngthread+0x1c6/frame 0xffffff800025a9a0 fork_exit() at fork_exit+0x114/frame 0xffffff800025a9f0 fork_trampoline() at fork_trampoline+0xe/frame 0xffffff800025a9f0 The reason is that soclose() closed the data socket while ngs_rcvdata() in ng_socket.c was still using it. ngs_rcvmsg() in the same file applies locking to prevent the race in r20830= 0, so we borrowed the idea to ngs_rcvdata() and got a patch attached here. We tested the patched system and the described problem does not happen anym= ore. --=20 You are receiving this mail because: You are the assignee for the bug.=