From nobody Sun Dec 19 14:43:09 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 013BC18F6C3F; Sun, 19 Dec 2021 14:43:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JH5714lcbz4v4D; Sun, 19 Dec 2021 14:43:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 830E22444E; Sun, 19 Dec 2021 14:43:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BJEh967072419; Sun, 19 Dec 2021 14:43:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BJEh9Ss072418; Sun, 19 Dec 2021 14:43:09 GMT (envelope-from git) Date: Sun, 19 Dec 2021 14:43:09 GMT Message-Id: <202112191443.1BJEh9Ss072418@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 71a1539e3783 - main - inet6: fix a LOR between rip and rawinp List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71a1539e378310120fede100b867ffa995fd9a7a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639924989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DKTefhvItWEMKqAH7X2RtYuqbcGumaz563YOilyPCPM=; b=C1oWlufcQbH8w+ILn23eigUWmpfdazrRKzAi1cfU0lLBWGQyU/OozP3eSpSZV5pQFpsbON OMqFiviD3sNv+zMd0pFRAeI6CTfivFwfyus0eRF3tZPD5rifO/1uIF+yl/BLcsfgAmc3uq GlrI/GtRxWvHqk3izPdune34fmq8r/Ur6tyV1Urs9RIV8XkRPKwJtRgbxK/PBMQ5tHbCEl bBPLGmeYkjg/A4S3xdAdSb+GBSVIsubcRCsV7Rud40529VhsWiR1C+KyDFiM8f/8aE7cM8 FO3GwCokI+mUDhLGXBTjTHmrjpciaZadqrczvTo2hsFOWRNtmDqWihj5Tya89Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639924989; a=rsa-sha256; cv=none; b=a++uW+6cy1hlaDZHhU5X0FgWsv7pEEXQyS9IAlMsMz4G7dtkY39yurokLGZSp3/7bFyi7F LOYz+LbmBKWYZ3Hl0Uo0oKQtTJbBG6D1sT0zewibDpt0h1feaFyH0E4adgTWAnNhwxfhaU ViddE3rXM2nqG67Bvaqxx65M08izXThNNT3kINBPOb+ykQalfGeoIpvhIn9NM0C3aa2onU bAnOGTe2UGw+3fplzjImxsrZtCGygm8ogPlSV0F7nfXjRymsE6lXrxnJ+USoj6nhJhKLD7 5nZMik2nluGzvVuDMjF6Pw5AfvxV99B7kKLH5hFtunz5GsPRS9yQsMbCE3lQ0Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=71a1539e378310120fede100b867ffa995fd9a7a commit 71a1539e378310120fede100b867ffa995fd9a7a Author: Mateusz Guzik AuthorDate: 2021-12-16 14:11:42 +0000 Commit: Mateusz Guzik CommitDate: 2021-12-19 14:43:04 +0000 inet6: fix a LOR between rip and rawinp Running sys/netpfil/pf/fragmentation v6 results in: lock order reversal: 1st 0xfffffe00050429a8 rip (rip, sleep mutex) @ /usr/src/sys/netinet6/raw_ip6.c:803 2nd 0xfffff8009491e1d0 rawinp (rawinp, rw) @ /usr/src/sys/netinet6/raw_ip6.c:804 lock order rawinp -> rip established at: 0xffffffff8068e26a at witness_lock_order_add+0x28a 0xffffffff8068d087 at witness_checkorder+0x627 0xffffffff805a9f05 at __mtx_lock_flags+0x205 0xffffffff808102e4 at in_pcballoc+0x204 0xffffffff808d53c6 at rip6_attach+0x116 0xffffffff806dc4e8 at socreate+0x368 0xffffffff806eaedc at kern_socket+0xfc 0xffffffff806eadcd at sys_socket+0x2d 0xffffffff80abc774 at syscallenter+0x5c4 0xffffffff80abbeeb at amd64_syscall+0x1b 0xffffffff80a8044b at fast_syscall_common+0xf8 lock order rip -> rawinp attempted at: 0xffffffff8068dc2a at witness_checkorder+0x11ca 0xffffffff805d1b7f at _rw_wlock_cookie+0x18f 0xffffffff808d596c at rip6_connect+0x19c 0xffffffff806e0842 at soconnectat+0x142 0xffffffff806ebe36 at kern_connectat+0x136 0xffffffff806ebcdf at sys_connect+0x4f 0xffffffff80abc774 at syscallenter+0x5c4 0xffffffff80abbeeb at amd64_syscall+0x1b 0xffffffff80a8044b at fast_syscall_common+0xf8 Reviewed by: glebius Fixes: de2d47842e880281 ("SMR protection for inpcbs") Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D33508 --- sys/netinet6/raw_ip6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 5b1790151009..cb54d1268cef 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -800,24 +800,24 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) return (error); - INP_INFO_WLOCK(&V_ripcbinfo); INP_WLOCK(inp); + INP_INFO_WLOCK(&V_ripcbinfo); /* Source address selection. XXX: need pcblookup? */ NET_EPOCH_ENTER(et); error = in6_selectsrc_socket(addr, inp->in6p_outputopts, inp, so->so_cred, scope_ambiguous, &in6a, NULL); NET_EPOCH_EXIT(et); if (error) { - INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_ripcbinfo); + INP_WUNLOCK(inp); return (error); } inp->in6p_faddr = addr->sin6_addr; inp->in6p_laddr = in6a; soisconnected(so); - INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_ripcbinfo); + INP_WUNLOCK(inp); return (0); }